form.fields
Attributes
Classes
dict() -> new empty dictionary |
|
A non-native version of the URL field that uses a default text field. |
|
Fixes the case for MS Edge Browser that returns the 'valuelist' |
|
Field base class |
|
A select field which translates the option labels. |
|
No different from a normal select field, except this one can take (and |
|
No different from a normal select field, except this one can take (and |
|
A custom file field that turns the uploaded file into a compressed |
|
Extends the upload field with onegov.file support. |
|
A custom file field that turns the uploaded files into a list of |
|
Extends the upload multiple field with onegov.file support. |
|
A textfield with text module selection/insertion. |
|
A non-native version of the URL field that uses a default text field. |
|
A textfield with html with integrated sanitation. |
|
A textfield with css validation. |
|
A textfield with markup with no sanitation. |
|
A tags field for use in conjunction with this library: |
|
Selects an icon out of a number of icons. |
|
A string field with support for phone numbers. |
|
A select field with chosen.js support. |
|
A multiple select field with chosen.js support. |
|
No different from a normal select field, except this one can take (and |
|
Field base class |
|
Shows a panel as part of the form (no input, no label). |
|
Shows a panel as part of the form (no input, no label). |
|
A custom implementation of the DateTimeLocalField to fix issues with |
|
A datetime field data returns the date with the given timezone |
|
A field to identify bots. |
|
A string field that renders a html5 color picker and coerces |
|
A string field with typeahead. |
|
Determines the level of geographical precision of autofill. |
|
Provides address completion for places (via mapbox_address_autofill.js). |
Module Contents
- class form.fields.FileDict[source]
Bases:
TypedDictdict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
- form.fields.FIELDS_NO_RENDERED_PLACEHOLDER = ('MultiCheckboxField', 'RadioField', 'OrderedMultiCheckboxField', 'UploadField',...[source]
- class form.fields.URLField(label: str | None = None, validators: onegov.form.types.Validators[onegov.form.types.FormT, Self] | None = None, filters: collections.abc.Sequence[onegov.form.types.Filter] = (), description: str = '', id: str | None = None, default: str | None = None, widget: onegov.form.types.Widget[Self] | None = None, render_kw: dict[str, Any] | None = None, name: str | None = None, default_scheme: str | None = 'https', _form: wtforms.form.BaseForm | None = None, _prefix: str = '', _translations: wtforms.meta._SupportsGettextAndNgettext | None = None, _meta: wtforms.meta.DefaultMeta | None = None, *, fieldset: str | None = None, depends_on: collections.abc.Sequence[Any] | None = None, pricing: onegov.form.types.PricingRules | None = None)[source]
Bases:
wtforms.fields.StringFieldA non-native version of the URL field that uses a default text field.
It instead relies on wtforms.validators.URL and normalizes URLs with missing scheme to use https:// or a given scheme by default. This behavior can be turned off by setting default_scheme to None.
- class form.fields.TimeField(label=None, validators=None, format='%H:%M', **kwargs)[source]
Bases:
wtforms.fields.TimeFieldFixes the case for MS Edge Browser that returns the ‘valuelist’ as [08:00:000] instead of [08:00:00]. This is only the case of the time is set with the js popup, not when switching the time e.g. with the arrow keys on the form.
- class form.fields.DurationField(label=None, validators=None, filters=(), description='', id=None, default=None, widget=None, render_kw=None, name=None, _form=None, _prefix='', _translations=None, _meta=None)[source]
Bases:
wtforms.fields.FieldField base class
- class form.fields.TranslatedSelectField(*args: Any, **kwargs: Any)[source]
Bases:
wtforms.fields.SelectFieldA select field which translates the option labels.
- class form.fields.MultiCheckboxField(label=None, validators=None, coerce=str, choices=None, validate_choice=True, **kwargs)[source]
Bases:
wtforms.fields.SelectMultipleFieldNo different from a normal select field, except this one can take (and validate) multiple choices. You’ll need to specify the HTML size attribute to the select field when rendering.
- class form.fields.OrderedMultiCheckboxField(label=None, validators=None, coerce=str, choices=None, validate_choice=True, **kwargs)[source]
Bases:
MultiCheckboxFieldNo different from a normal select field, except this one can take (and validate) multiple choices. You’ll need to specify the HTML size attribute to the select field when rendering.
- class form.fields.UploadField(label: str | None = None, validators: onegov.form.types.Validators[onegov.form.types.FormT, Self] | None = None, filters: collections.abc.Sequence[onegov.form.types.Filter] = (), description: str = '', id: str | None = None, default: collections.abc.Sequence[onegov.core.types.FileDict] = (), widget: onegov.form.types.Widget[Self] | None = None, render_kw: dict[str, Any] | None = None, name: str | None = None, _form: wtforms.form.BaseForm | None = None, _prefix: str = '', _translations: wtforms.meta._SupportsGettextAndNgettext | None = None, _meta: wtforms.meta.DefaultMeta | None = None, *, fieldset: str | None = None, depends_on: collections.abc.Sequence[Any] | None = None, pricing: onegov.form.types.PricingRules | None = None)[source]
Bases:
wtforms.fields.FileFieldA custom file field that turns the uploaded file into a compressed base64 string together with the filename, size and mimetype.
- class form.fields.UploadFileWithORMSupport(*args: Any, **kwargs: Any)[source]
Bases:
UploadFieldExtends the upload field with onegov.file support.
- class form.fields.UploadMultipleField(label: str | None = None, validators: onegov.form.types.Validators[onegov.form.types.FormT, UploadField] | None = None, filters: collections.abc.Sequence[onegov.form.types.Filter] = (), description: str = '', id: str | None = None, default: collections.abc.Sequence[FileDict] = (), widget: onegov.form.types.Widget[Self] | None = None, render_kw: dict[str, Any] | None = None, name: str | None = None, upload_widget: onegov.form.types.Widget[UploadField] | None = None, _form: wtforms.form.BaseForm | None = None, _prefix: str = '', _translations: wtforms.meta._SupportsGettextAndNgettext | None = None, _meta: wtforms.meta.DefaultMeta | None = None, *, fieldset: str | None = None, depends_on: collections.abc.Sequence[Any] | None = None, pricing: onegov.form.types.PricingRules | None = None, **extra_arguments: Any)[source]
Bases:
UploadMultipleBase,wtforms.fields.FileFieldA custom file field that turns the uploaded files into a list of compressed base64 strings together with the filename, size and mimetype.
This acts both like a single file field with multiple and like a list of
onegov.form.fields.UploadFilefor uploaded files. This way we get the best of both worlds.- upload_field_class: type[UploadField][source]
- upload_widget: onegov.form.types.Widget[UploadField][source]
- process(formdata: wtforms.meta._MultiDictLikeWithGetlist | None, data: object = unset_value, extra_filters: collections.abc.Sequence[onegov.form.types.Filter] | None = None) None[source]
Process incoming data, calling process_data, process_formdata as needed, and run filters.
If data is not provided, process_data will be called on the field’s default.
Field subclasses usually won’t override this, instead overriding the process_formdata and process_data methods. Only override this for special advanced processing, such as when a field encapsulates many inputs.
- Parameters:
extra_filters – A sequence of extra filters to run.
- append_entry_from_field_storage(fs: webob.request._FieldStorageWithFile) UploadField[source]
- class form.fields.UploadMultipleFilesWithORMSupport(*args: Any, **kwargs: Any)[source]
Bases:
UploadMultipleFieldExtends the upload multiple field with onegov.file support.
- class form.fields.TextAreaFieldWithTextModules(label=None, validators=None, filters=(), description='', id=None, default=None, widget=None, render_kw=None, name=None, _form=None, _prefix='', _translations=None, _meta=None)[source]
Bases:
wtforms.fields.TextAreaFieldA textfield with text module selection/insertion.
- class form.fields.VideoURLField(label: str | None = None, validators: onegov.form.types.Validators[onegov.form.types.FormT, Self] | None = None, filters: collections.abc.Sequence[onegov.form.types.Filter] = (), description: str = '', id: str | None = None, default: str | None = None, widget: onegov.form.types.Widget[Self] | None = None, render_kw: dict[str, Any] | None = None, name: str | None = None, default_scheme: str | None = 'https', _form: wtforms.form.BaseForm | None = None, _prefix: str = '', _translations: wtforms.meta._SupportsGettextAndNgettext | None = None, _meta: wtforms.meta.DefaultMeta | None = None, *, fieldset: str | None = None, depends_on: collections.abc.Sequence[Any] | None = None, pricing: onegov.form.types.PricingRules | None = None)[source]
Bases:
URLFieldA non-native version of the URL field that uses a default text field.
It instead relies on wtforms.validators.URL and normalizes URLs with missing scheme to use https:// or a given scheme by default. This behavior can be turned off by setting default_scheme to None.
- class form.fields.HtmlField(*args: Any, **kwargs: Any)[source]
Bases:
wtforms.fields.TextAreaFieldA textfield with html with integrated sanitation.
- class form.fields.CssField(label=None, validators=None, filters=(), description='', id=None, default=None, widget=None, render_kw=None, name=None, _form=None, _prefix='', _translations=None, _meta=None)[source]
Bases:
wtforms.fields.TextAreaFieldA textfield with css validation.
- post_validate(form: wtforms.form.BaseForm, validation_stopped: bool) None[source]
Override if you need to run any field-level validation tasks after normal validation. This shouldn’t be needed in most cases.
- Parameters:
form – The form the field belongs to.
validation_stopped – True if any validator raised StopValidation.
- class form.fields.MarkupField(label=None, validators=None, filters=(), description='', id=None, default=None, widget=None, render_kw=None, name=None, _form=None, _prefix='', _translations=None, _meta=None)[source]
Bases:
wtforms.fields.TextAreaFieldA textfield with markup with no sanitation.
This field is inherently unsafe and should be avoided, use with care!
- class form.fields.TagsField(label=None, validators=None, filters=(), description='', id=None, default=None, widget=None, render_kw=None, name=None, _form=None, _prefix='', _translations=None, _meta=None)[source]
Bases:
wtforms.fields.StringFieldA tags field for use in conjunction with this library:
- class form.fields.IconField(label=None, validators=None, filters=(), description='', id=None, default=None, widget=None, render_kw=None, name=None, _form=None, _prefix='', _translations=None, _meta=None)[source]
Bases:
wtforms.fields.StringFieldSelects an icon out of a number of icons.
- class form.fields.PhoneNumberField(*args: Any, country: str = 'CH', **kwargs: Any)[source]
Bases:
wtforms.fields.TelFieldA string field with support for phone numbers.
- class form.fields.ChosenSelectField(label=None, validators=None, coerce=str, choices=None, validate_choice=True, **kwargs)[source]
Bases:
wtforms.fields.SelectFieldA select field with chosen.js support.
- class form.fields.ChosenSelectMultipleField(label=None, validators=None, coerce=str, choices=None, validate_choice=True, **kwargs)[source]
Bases:
wtforms.fields.SelectMultipleFieldA multiple select field with chosen.js support.
- class form.fields.ChosenSelectMultipleEmailField(label=None, validators=None, coerce=str, choices=None, validate_choice=True, **kwargs)[source]
Bases:
wtforms.fields.SelectMultipleFieldNo different from a normal select field, except this one can take (and validate) multiple choices. You’ll need to specify the HTML size attribute to the select field when rendering.
- class form.fields.PreviewField(*args: Any, fields: collections.abc.Sequence[str] = (), url: collections.abc.Callable[[wtforms.meta.DefaultMeta], str | None] | str | None = None, events: collections.abc.Sequence[str] = (), display: str = 'inline', **kwargs: Any)[source]
Bases:
wtforms.fields.FieldField base class
- class form.fields.PanelField(*args: Any, text: str, kind: str, hide_label: bool = True, **kwargs: Any)[source]
Bases:
wtforms.fields.FieldShows a panel as part of the form (no input, no label).
- class form.fields.URLPanelField(*args: Any, text: str, kind: str, hide_label: bool = True, **kwargs: Any)[source]
Bases:
PanelFieldShows a panel as part of the form (no input, no label).
- class form.fields.DateTimeLocalField(label: str | None = None, validators: onegov.form.types.Validators[onegov.form.types.FormT, Self] | None = None, format: str = '%Y-%m-%dT%H:%M', **kwargs: Any)[source]
Bases:
wtforms.fields.DateTimeLocalFieldA custom implementation of the DateTimeLocalField to fix issues with the format and the datetimepicker plugin.
- class form.fields.TimezoneDateTimeField(*args: Any, timezone: str, **kwargs: Any)[source]
Bases:
DateTimeLocalFieldA datetime field data returns the date with the given timezone and expects dateime values with a timezone.
Used together with
onegov.core.orm.types.UTCDateTime.
- class form.fields.HoneyPotField(*args: Any, **kwargs: Any)[source]
Bases:
wtforms.fields.StringFieldA field to identify bots.
A honey pot field is hidden using CSS and therefore not visible for users but bots (probably). We therefore expect this field to be empty at any time and throw an error if provided as well as adding a log message to optionally ban the IP.
To add honey pot fields to your (public) forms, give it a reasonable name, but not one that might be autofilled by browsers, e.g.:
delay = HoneyPotField()
- post_validate(form: onegov.form.Form, validation_stopped: bool) None[source]
Override if you need to run any field-level validation tasks after normal validation. This shouldn’t be needed in most cases.
- Parameters:
form – The form the field belongs to.
validation_stopped – True if any validator raised StopValidation.
- class form.fields.ColorField(label=None, validators=None, filters=(), description='', id=None, default=None, widget=None, render_kw=None, name=None, _form=None, _prefix='', _translations=None, _meta=None)[source]
Bases:
wtforms.fields.StringFieldA string field that renders a html5 color picker and coerces to a normalized six digit hex string.
It will result in a process_error for invalid colors.
- class form.fields.TypeAheadField(*args: Any, url: collections.abc.Callable[[wtforms.meta.DefaultMeta], str | None] | str | None = None, **kwargs: Any)[source]
Bases:
wtforms.fields.StringFieldA string field with typeahead.
Requires an url with the placeholder %QUERY for the search term.
- class form.fields.MapboxPlaceDetail(*args, **kwds)[source]
Bases:
enum.EnumDetermines the level of geographical precision of autofill.
- class form.fields.PlaceAutocompleteField(autocomplete_attribute: MapboxPlaceDetail | None = None, *args: Any, **kwargs: Any)[source]
Bases:
wtforms.fields.StringFieldProvides address completion for places (via mapbox_address_autofill.js).