flask_admin.form.fields

class TimeField(*args, **kwargs)[source]

A text field which stores a datetime.time object. Accepts time string in multiple formats: 20:10, 20:10:00, 10:00 am, 9:30pm, etc.

Constructor

Parameters:
  • label – Label

  • validators – Field validators

  • formats – Supported time formats, as a enumerable.

  • default_format – Default time format. Defaults to ‘%H:%M:%S’

  • kwargs – Any additional parameters

process_formdata(valuelist: Iterable[str]) None[source]

Process data received over the wire from a form.

This will be called during form construction with data supplied through the formdata argument.

Parameters:

valuelist – A list of strings to process.

class Select2Field(*args, **kwargs)[source]

Select2 styled select widget.

You must include select2.js, form-x.x.x.js and select2 stylesheet for it to work.

Construct a new field.

Parameters:
  • label – The label of the field.

  • validators – A sequence of validators to call when validate is called.

  • filters – A sequence of callable which are run by process() to filter or transform the input data. For example StringForm(filters=[str.strip, str.upper]). Note that filters are applied after processing the default and incoming data, but before validation.

  • description – A description for the field, typically used for help text.

  • id – An id to use for the field. A reasonable default is set by the form, and you shouldn’t need to set this manually.

  • default – The default value to assign to the field, if no form or object input is provided. May be a callable.

  • widget – If provided, overrides the widget used to render the field.

  • render_kw (dict) – If provided, a dictionary which provides default keywords that will be given to the widget at render time.

  • name – The HTML name of this field. The default value is the Python attribute name.

  • _form – The form holding this field. It is passed by the form itself during construction. You should never pass this value yourself.

  • _prefix – The prefix to prepend to the form name of this field, passed by the enclosing form during construction.

  • _translations – A translations object providing message translations. Usually passed by the enclosing form during construction. See I18n docs for information on message translations.

  • _meta – If provided, this is the ‘meta’ instance from the form. You usually don’t pass this yourself.

If _form isn’t provided, an UnboundField will be returned instead. Call its bind() method with a form instance and a name to construct the field.

iter_choices() Iterator[tuple[Any, str | flask_babel.LazyString, bool, dict[str, Any]] | tuple[Any, str | flask_babel.LazyString, bool]][source]

Provides data for choice widget rendering. Must return a sequence or iterable of (value, label, selected, render_kw) tuples.

pre_validate(form: BaseForm) None[source]

Override if you need field-level validation. Runs before any other validators.

Parameters:

form – The form the field belongs to.

process_data(value: Any) None[source]

Process the Python data applied to this field and store the result.

This will be called during form construction by the form’s kwargs or obj argument.

Parameters:

value – The python object containing the value to process.

process_formdata(valuelist: Sequence[str] | None) None[source]

Process data received over the wire from a form.

This will be called during form construction with data supplied through the formdata argument.

Parameters:

valuelist – A list of strings to process.

class Select2TagsField(*args, **kwargs)[source]

Select2Tags styled text field.

You must include select2.js, form-x.x.x.js and select2 stylesheet for it to work.

Initialization

Parameters:
  • save_as_list – If True then populate obj using list else string

  • allow_duplicates – If True then duplicate tags are allowed in the field.

process_formdata(valuelist: Sequence[str] | None = None) None[source]

Process data received over the wire from a form.

This will be called during form construction with data supplied through the formdata argument.

Parameters:

valuelist – A list of strings to process.