form.widgets
Classes
Extends the default list widget with automated ordering using the |
|
The default list widget with the label behind the checkbox. |
|
The sorted list widget with the label behind the checkbox. |
|
Widget containing the coordinates for the |
|
An upload widget for the |
|
A widget for the |
|
An extension of a regular textarea with a button that lets |
|
Render a single-line text input. |
|
Render a single-line text input. |
|
Renders a select field. |
|
A widget that displays the html of a specific view whenever there's |
|
A widget that displays the field's text as panel (no input). |
|
A widget that displays the input normally not visible to the user. |
|
A date widget which set the min and max values that are |
|
A datetime-local widget which set the min and max values that |
|
A widget with typeahead. |
Module Contents
- class form.widgets.OrderedListWidget(html_tag='ul', prefix_label=True)[source]
Bases:
wtforms.widgets.ListWidget
Extends the default list widget with automated ordering using the translated text of each element.
- class form.widgets.MultiCheckboxWidget(html_tag: Literal['ul', 'ol'] = 'ul')[source]
Bases:
wtforms.widgets.ListWidget
The default list widget with the label behind the checkbox.
- class form.widgets.OrderedMultiCheckboxWidget(html_tag: Literal['ul', 'ol'] = 'ul')[source]
Bases:
MultiCheckboxWidget
,OrderedListWidget
The sorted list widget with the label behind the checkbox.
- class form.widgets.CoordinateWidget(input_type=None)[source]
Bases:
wtforms.widgets.TextInput
Widget containing the coordinates for the
onegov.form.fields.CoordinateField
class.Basically a text input with a class. Meant to be enhanced on the browser using javascript.
- class form.widgets.UploadWidget(multiple=False)[source]
Bases:
wtforms.widgets.FileInput
An upload widget for the
onegov.form.fields.UploadField
class, which supports keeping, removing and replacing already uploaded files.This is necessary as file inputs are read-only on the client and it’s therefore rather easy for users to lose their input otherwise (e.g. a form with a file is rejected because of some mistake - the file disappears once the response is rendered on the client).
- image_source(field: onegov.form.fields.UploadField) str | None [source]
Returns the image source url if the field points to an image and if it can be done (it looks like it’s possible, but I’m not super sure this is always possible).
- class form.widgets.UploadMultipleWidget[source]
Bases:
wtforms.widgets.FileInput
A widget for the
onegov.form.fields.UploadMultipleField
class, which supports keeping, removing and replacing already uploaded files.This is necessary as file inputs are read-only on the client and it’s therefore rather easy for users to lose their input otherwise (e.g. a form with a file is rejected because of some mistake - the file disappears once the response is rendered on the client).
We deviate slightly from the norm by rendering the errors ourselves since we’re essentially a list of fields and not a single field most of the time.
- class form.widgets.TextAreaWithTextModules[source]
Bases:
wtforms.widgets.TextArea
An extension of a regular textarea with a button that lets you select and insert text modules. If no text modules have been defined this will be no different from textarea.
- class form.widgets.TagsWidget(input_type=None)[source]
Bases:
wtforms.widgets.TextInput
Render a single-line text input.
- class form.widgets.IconWidget(input_type=None)[source]
Bases:
wtforms.widgets.TextInput
Render a single-line text input.
- class form.widgets.ChosenSelectWidget(multiple=False)[source]
Bases:
wtforms.widgets.Select
Renders a select field.
If multiple is True, then the size property should be specified on rendering to make the field useful.
The field must provide an iter_choices() method which the widget will call on rendering; this method must yield tuples of (value, label, selected) or (value, label, selected, render_kw). It also must provide a has_groups() method which tells whether choices are divided into groups, and if they do, the field must have an iter_groups() method that yields tuples of (label, choices), where choices is a iterable of (value, label, selected) tuples.
- class form.widgets.PreviewWidget[source]
A widget that displays the html of a specific view whenever there’s a change in other fields. JavaScript is used to facilitate this.
- class form.widgets.PanelWidget[source]
A widget that displays the field’s text as panel (no input).
- class form.widgets.HoneyPotWidget(input_type=None)[source]
Bases:
wtforms.widgets.TextInput
A widget that displays the input normally not visible to the user.
- class form.widgets.DateRangeMixin(min: datetime.date | dateutil.relativedelta.relativedelta | None = None, max: datetime.date | dateutil.relativedelta.relativedelta | None = None)[source]
- class form.widgets.DateRangeInput(min: datetime.date | dateutil.relativedelta.relativedelta | None = None, max: datetime.date | dateutil.relativedelta.relativedelta | None = None)[source]
Bases:
DateRangeMixin
,wtforms.widgets.DateInput
A date widget which set the min and max values that are supported in some browsers based on a date or relativedelta.
- class form.widgets.DateTimeLocalRangeInput(min: datetime.date | dateutil.relativedelta.relativedelta | None = None, max: datetime.date | dateutil.relativedelta.relativedelta | None = None)[source]
Bases:
DateRangeMixin
,wtforms.widgets.DateTimeLocalInput
A datetime-local widget which set the min and max values that are supported in some browsers based on a date or relativedelta.