form.fields
Attributes
Classes
dict() -> new empty dictionary |
|
Fixes the case for MS Edge Browser that returns the 'valuelist' |
|
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. |
|
Represents an |
|
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). |
|
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. |
Module Contents
- class form.fields.FileDict[source]
Bases:
TypedDict
dict() -> 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.TimeField(label=None, validators=None, format='%H:%M', **kwargs)[source]
Bases:
wtforms.fields.TimeField
Fixes 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.TranslatedSelectField(label=None, validators=None, coerce=str, choices=None, validate_choice=True, **kwargs)[source]
Bases:
wtforms.fields.SelectField
A 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.SelectMultipleField
No 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:
MultiCheckboxField
No 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: Validators[FormT, Self] | None = None, filters: Sequence[Filter] = (), description: str = '', id: str | None = None, default: Sequence[StrictFileDict] = (), widget: Widget[Self] | None = None, render_kw: dict[str, Any] | None = None, name: str | None = None, _form: BaseForm | None = None, _prefix: str = '', _translations: _SupportsGettextAndNgettext | None = None, _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.FileField
A 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:
UploadField
Extends the upload field with onegov.file support.
- class form.fields.UploadMultipleField(label: str | None = None, validators: Validators[FormT, UploadField] | None = None, filters: Sequence[Filter] = (), description: str = '', id: str | None = None, default: Sequence[FileDict] = (), widget: Widget[Self] | None = None, render_kw: dict[str, Any] | None = None, name: str | None = None, upload_widget: Widget[UploadField] | None = None, _form: BaseForm | None = None, _prefix: str = '', _translations: _SupportsGettextAndNgettext | None = None, _meta: DefaultMeta | None = None, *, fieldset: str | None = None, depends_on: Sequence[Any] | None = None, pricing: PricingRules | None = None, **extra_arguments: Any)[source]
Bases:
UploadMultipleBase
,wtforms.fields.FileField
A 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.UploadFile
for uploaded files. This way we get the best of both worlds.- upload_field_class: type[UploadField][source]
- upload_widget: Widget[UploadField][source]
- process(formdata: _MultiDictLikeWithGetlist | None, data: object = unset_value, extra_filters: Sequence[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:
UploadMultipleField
Extends 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.TextAreaField
A textfield with text module selection/insertion.
- class form.fields.VideoURLField(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.simple.URLField
Represents an
<input type="url">
.
- class form.fields.HtmlField(*args: Any, **kwargs: Any)[source]
Bases:
wtforms.fields.TextAreaField
A 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.TextAreaField
A 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.TextAreaField
A 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.StringField
A 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.StringField
Selects an icon out of a number of icons.
- class form.fields.PhoneNumberField(*args: Any, country: str = 'CH', **kwargs: Any)[source]
Bases:
wtforms.fields.TelField
A 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.SelectField
A 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.SelectMultipleField
A 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.SelectMultipleField
No 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: Sequence[str] = (), url: Callable[[DefaultMeta], str | None] | str | None = None, events: Sequence[str] = (), display: str = 'inline', **kwargs: Any)[source]
Bases:
wtforms.fields.Field
Field base class
- class form.fields.PanelField(*args: Any, text: str, kind: str, hide_label: bool = True, **kwargs: Any)[source]
Bases:
wtforms.fields.Field
Shows a panel as part of the form (no input, no label).
- class form.fields.DateTimeLocalField(label: str | None = None, validators: Validators[FormT, Self] | None = None, format: str = '%Y-%m-%dT%H:%M', **kwargs: Any)[source]
Bases:
wtforms.fields.DateTimeLocalField
A 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:
DateTimeLocalField
A 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.StringField
A 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.StringField
A 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.