Skip to main content

Decorator driven wtforms extension with Bootstrap 5 support for Flask

Project description

wtforms-widgets

Decorator driven wtforms extension with Bootstrap 5 support for Flask

Copyright (c) The Pycroft Authors. See the AUTHORS file.

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">
    {% for field in form %}
        {{ field(render_mode='horizontal', autocomplete='off') }}
    {% endfor %}
    <input type="submit" value="submit">
</form>

Available field types

  • SelectField
  • SelectMultipleField
  • RadioField
  • StringField / TextField
  • IntegerField
  • DecimalField
  • MoneyField
  • FloatField
  • BooleanField
  • DateTimeField
  • DateField (with bootstrap-datepicker)
  • TextAreaField
  • PasswordField
  • FileField
  • HiddenField
  • SubmitField
  • QuerySelectField
  • QuerySelectMultipleField
  • FieldList
  • FormField
  • TypeaheadField
  • ReadonlyTextField
  • MacField

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wtforms_widgets-1.0.9.tar.gz (12.3 kB view hashes)

Uploaded Source

Built Distribution

wtforms_widgets-1.0.9-py3-none-any.whl (14.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page