form.widgets

Classes

OrderedListWidget

Extends the default list widget with automated ordering using the

MultiCheckboxWidget

The default list widget with the label behind the checkbox.

OrderedMultiCheckboxWidget

The sorted list widget with the label behind the checkbox.

CoordinateWidget

Widget containing the coordinates for the

UploadWidget

An upload widget for the onegov.form.fields.UploadField class,

UploadMultipleWidget

A widget for the onegov.form.fields.UploadMultipleField class,

TextAreaWithTextModules

An extension of a regular textarea with a button that lets

TagsWidget

Render a single-line text input.

IconWidget

Render a single-line text input.

ChosenSelectWidget

Renders a select field.

PreviewWidget

A widget that displays the html of a specific view whenever there's

PanelWidget

A widget that displays the field's text as panel (no input).

HoneyPotWidget

A widget that displays the input normally not visible to the user.

DateRangeMixin

DateRangeInput

A date widget which set the min and max values that are

DateTimeLocalRangeInput

A datetime-local widget which set the min and max values that

TypeAheadInput

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.

__call__(field: wtforms.Field, **kwargs: Any) markupsafe.Markup[source]
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.

__call__(field: wtforms.Field, **kwargs: Any) markupsafe.Markup[source]
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).

simple_template[source]
template[source]
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).

template_data(field: onegov.form.fields.UploadField, force_simple: bool, resend_upload: bool, wrapper_css_class: str, input_html: markupsafe.Markup, **kwargs: Any) tuple[bool, dict[str, Any]][source]
__call__(field: onegov.form.fields.UploadField, **kwargs: Any) markupsafe.Markup[source]
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.

additional_label[source]
multiple = True[source]
render_input(field: onegov.form.fields.UploadMultipleField, **kwargs: Any) markupsafe.Markup[source]
__call__(field: onegov.form.fields.UploadMultipleField, **kwargs: Any) markupsafe.Markup[source]
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.

template[source]
text_modules(field: wtforms.StringField) list[onegov.chat.TextModule][source]
__call__(field: wtforms.StringField, **kwargs: Any) markupsafe.Markup[source]
class form.widgets.TagsWidget(input_type=None)[source]

Bases: wtforms.widgets.TextInput

Render a single-line text input.

input_type = 'tags'[source]
class form.widgets.IconWidget(input_type=None)[source]

Bases: wtforms.widgets.TextInput

Render a single-line text input.

iconfont = 'FontAwesome'[source]
icons[source]
template[source]
__call__(field: wtforms.Field, **kwargs: Any) markupsafe.Markup[source]
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.

__call__(field: wtforms.fields.choices.SelectFieldBase, **kwargs: Any) markupsafe.Markup[source]
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.

template[source]
__call__(field: onegov.form.fields.PreviewField, **kwargs: Any) markupsafe.Markup[source]
class form.widgets.PanelWidget[source]

A widget that displays the field’s text as panel (no input).

__call__(field: onegov.form.fields.PanelField, **kwargs: Any) markupsafe.Markup[source]
class form.widgets.HoneyPotWidget(input_type=None)[source]

Bases: wtforms.widgets.TextInput

A widget that displays the input normally not visible to the user.

__call__(field: wtforms.Field, **kwargs: Any) markupsafe.Markup[source]
class form.widgets.DateRangeMixin(min: datetime.date | dateutil.relativedelta.relativedelta | None = None, max: datetime.date | dateutil.relativedelta.relativedelta | None = None)[source]
min = None[source]
max = None[source]
property min_date: datetime.date | None[source]
property max_date: datetime.date | 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.

__call__(field: wtforms.Field, **kwargs: Any) markupsafe.Markup[source]
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.

__call__(field: wtforms.Field, **kwargs: Any) markupsafe.Markup[source]
class form.widgets.TypeAheadInput(input_type=None)[source]

Bases: wtforms.widgets.TextInput

A widget with typeahead.

__call__(field: onegov.form.fields.TypeAheadField, **kwargs: Any) markupsafe.Markup[source]