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
- 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 exampleStringForm(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
UnboundFieldwill be returned instead. Call itsbind()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.
- 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
objusing list else stringallow_duplicates – If True then duplicate tags are allowed in the field.