Skip to content

Instantly share code, notes, and snippets.

@ryanpadilha
Created February 27, 2019 13:56
Show Gist options
  • Select an option

  • Save ryanpadilha/3790a851df2ad6b200cb17f0eac93f3e to your computer and use it in GitHub Desktop.

Select an option

Save ryanpadilha/3790a851df2ad6b200cb17f0eac93f3e to your computer and use it in GitHub Desktop.
Multiple checkbox field using WTForms with flask_wtf
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