Created
February 27, 2019 13:56
-
-
Save ryanpadilha/3790a851df2ad6b200cb17f0eac93f3e to your computer and use it in GitHub Desktop.
Multiple checkbox field using WTForms with flask_wtf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask_wtf import FlaskForm | |
| from wtforms import StringField, SelectMultipleField | |
| from wtforms.widgets import ListWidget, CheckboxInput | |
| from wtforms.validators import Required | |
| class MultiCheckboxField(SelectMultipleField): | |
| widget = ListWidget(prefix_label=False) | |
| option_widget = CheckboxInput() | |
| class FormProject(FlaskForm): | |
| Code = StringField('Code', [Required(message='Please enter your code')]) | |
| Tasks = MultiCheckboxField('Proses', [Required(message='Please tick your task')], choices=[('nyapu','Nyapu'), ('ngepel','Ngepel')]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment