class QueryRadioSelectField(QuerySelectField): """ Works the same as a QuerySelectField, except using radio buttons rather than a selectbox. Iterating over the field yields the radio subfields. """ widget = widgets.ListWidget(prefix_label=False) option_widget = widgets.RadioInput()
class RadioField(SelectField): """ Like a SelectField, except displays a list of radio buttons. Iterating the field will produce subfields (each containing a label as well) in order to allow custom rendering of the individual radio fields. """ widget = widgets.ListWidget(prefix_label=False) option_widget = widgets.RadioInput()
class RadioBoxField(fields.SelectField): """ A multiple-select, except displays a list of checkboxes. Iterating the field will produce subfields, allowing custom rendering of the enclosed checkbox fields. """ widget = CheckboxGroup(inline=True) option_widget = widgets.RadioInput()
class RadioBooleanField(RadioField): widget = InlineListWidget() option_widget = widgets.RadioInput() def process_formdata(self, valuelist): if 'False' in valuelist: self.data = False elif 'True' in valuelist: self.data = True else: self.data = False
class CodeForm(Form): content = CodeMirrorField('content') file_name = fields.HiddenField('file_name') submit = fields.SubmitField('submit') theme = fields.SelectField('Theme', choices=theme_choice) mode = fields.SelectField('mode', choices=mode_choice) test_select = fields.SelectField( 'test', choices=test_choice, option_widget=widgets.RadioInput(), widget=widgets.ListWidget(prefix_label=False))
class EditUserRoleForm(FlaskForm): roles = MultiCheckboxField('roles', option_widget=widgets.RadioInput()) submit = SubmitField('Submit')
from functools import partial from wtforms import BooleanField, validators, HiddenField, widgets, StringField, DateField, TextAreaField from wtforms import SelectField as SelectFieldW from wtforms.ext.sqlalchemy.fields import QuerySelectField from wtforms_alchemy import ModelFieldList from dexter.forms import ModelForm, FormField, MultiCheckboxField, IntegerField, SelectField, RadioField, YesNoField, FloatField from dexter.models import * # noqa QueryRadioField = partial(QuerySelectField, widget=widgets.ListWidget(prefix_label=False), option_widget=widgets.RadioInput()) class DocumentSourceForm(ModelForm): """ Form for editing a document source. """ class Meta: model = DocumentSource only = ['name', 'quoted', 'photographed'] field_args = {'name': {'label': 'Name'}} id = HiddenField('id', [validators.Optional()]) deleted = HiddenField('deleted', default='0') person_id = IntegerField('person_id', widget=widgets.HiddenInput()) named = BooleanField('The source is named', default=True) source_type = RadioField( 'Type', default='person', choices=[['person', 'Adult'], ['child', 'Child'],
class RadioButtonField(SelectField): """Radio button field""" widget = widgets.ListWidget(prefix_label=False) option_widget = widgets.RadioInput()
class CustomRadioField(CustomSelectField): pre_validate = lambda self, form: None widget = ListWidgetWithReset(prefix_label=False) option_widget = widgets.RadioInput()
class QueryRadioField(QuerySelectField): widget = widgets.ListWidget(prefix_label=False) option_widget = widgets.RadioInput()
class CheckboxField(SelectField): widget = widgets.ListWidget(prefix_label=False) option_widget = widgets.RadioInput()
class BooleanField(f.RadioField): widget = widgets.BooleanWidget() option_widget = w.RadioInput()
class KRadioField(fields.SelectField): widget = KListWidget(html_tag='div', sub_tag='label', prefix_label=False) option_widget = widgets.RadioInput()