https://github.com/agdsn/wtforms-widgets
Decorator driven wtforms extension with Bootstrap 5 support
https://github.com/agdsn/wtforms-widgets
Last synced: 4 months ago
JSON representation
Decorator driven wtforms extension with Bootstrap 5 support
- Host: GitHub
- URL: https://github.com/agdsn/wtforms-widgets
- Owner: agdsn
- License: apache-2.0
- Created: 2020-06-07T16:29:17.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-17T11:55:01.000Z (7 months ago)
- Last Synced: 2024-11-06T14:45:57.171Z (5 months ago)
- Language: Python
- Homepage:
- Size: 88.9 KB
- Stars: 6
- Watchers: 11
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - agdsn/wtforms-widgets - Decorator driven wtforms extension with Bootstrap 5 support (Python)
README
# wtforms-widgets
Decorator driven wtforms extension with Bootstrap 5 support for FlaskCopyright (c) The Pycroft Authors. See the [AUTHORS](https://github.com/agdsn/pycroft/blob/develop/AUTHORS) file.
Install with
```shell
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`.
```python
from wtforms import validatorsfrom wtforms.validators import Email
from wtforms_widgets.base_form import BaseForm
from wtforms_widgets.fields.core import StringField, PasswordFieldclass 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.
```html+jinja{% for field in form %}
{{ field(render_mode='horizontal', autocomplete='off') }}
{% endfor %}
```
# Available field types
- `SelectField`
- `SelectMultipleField`
- `RadioField`
- `StringField` / `TextField`
- `IntegerField`
- `DecimalField`
- `MoneyField`
- `FloatField`
- `BooleanField`
- `DateTimeField`
- `DateField` (with [bootstrap-datepicker](https://www.npmjs.com/package/bootstrap-datepicker))
- `TextAreaField`
- `PasswordField`
- `FileField`
- `HiddenField`
- `SubmitField`
- `QuerySelectField`
- `QuerySelectMultipleField`
- `FieldList`
- `FormField`
- `TypeaheadField`
- `ReadonlyTextField`
- `MacField`