Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation #1

Open
ibot3 opened this issue Jun 7, 2020 · 3 comments
Open

Improve documentation #1

ibot3 opened this issue Jun 7, 2020 · 3 comments

Comments

@ibot3
Copy link
Member

ibot3 commented Jun 7, 2020

The documentation must be improved.

@peteristhegreat
Copy link

peteristhegreat commented Mar 6, 2021

This is a well written module! I can put some basic docs here:

Install with

pip install wtforms-widgets

Initialize your form with wtforms_widgets.base_form.BaseForm instead of flask_wtf.FlaskForm or wtforms.Form.

Import the StringField and PasswordField from wtforms_widgets.fields.core.

from wtforms import validators

from wtforms.validators import Email
from wtforms_widgets.base_form import BaseForm
from wtforms_widgets.fields.core import StringField, PasswordField

class RegisterForm(BaseForm):
    email = StringField('Email Address', [Email(), validators.DataRequired(message='Forgot your email address?')])
    password = PasswordField('Password', [validators.DataRequired(message='Must provide a password. ;-)')])

Displaying the form in jinja is much simpler and looks great.

<form method="POST" action="{{ url_for('auth.register') }}" accept-charset="UTF-8" role="form">
    {{ form.csrf_token }}
    {{ form.name }}
     {% for error in form.name.errors %}
      <div class="invalid-feedback">{{ error }}</div>
     {% endfor %}
     {{ form.password }}
     {% for error in form.password.errors %}
      <div class="invalid-feedback">{{ error }}</div>
     {% endfor %}
     {{ form.email }}
     {% for error in form.email.error %}
      <div class="invalid-feedback">{{ error }}</div>
     {% endfor %}
     <input type="submit" value="submit">
</form>

ibot3 added a commit that referenced this issue Mar 7, 2021
@ibot3
Copy link
Member Author

ibot3 commented Mar 7, 2021

Thanks for the submission. I updated the readme file with more information. However, your example is more complicated as required, because you are not using the already implemented form rendering. You can find an example in the readme.

@peteristhegreat
Copy link

Awesome! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants