FieldList¶
- class bootlace.forms.fields.FieldList(*args, **kwargs)[source]¶
Bases:
FieldEncapsulate an ordered list of multiple instances of the same field type, keeping data as a list.
>>> authors = FieldList(StringField('Name', [validators.DataRequired()]))
- Parameters:
unbound_field – A partially-instantiated field definition, just like that would be defined on a form directly.
min_entries – if provided, always have at least this many entries on the field, creating blank ones if the provided input does not specify a sufficient amount.
max_entries – accept no more than this many entries as input, even if more exist in formdata.
separator – A string which will be suffixed to this field’s name to create the prefix to enclosed list entries. The default is fine for most uses.
Attributes Summary
Methods Summary
__call__(**kwargs)Render this field as HTML, using keyword args as additional attributes.
append_entry([data])Create a new entry with optional default data.
check_validators(validators)gettext(string)Get a translation for the given message.
ngettext(singular, plural, n)Get a translation for a message which can be pluralized.
Removes the last entry from the list and returns it.
populate_obj(obj, name)Populates obj.<name> with the field's data.
post_validate(form, validation_stopped)Override if you need to run any field-level validation tasks after normal validation.
pre_validate(form)Override if you need field-level validation.
process(formdata[, data, extra_filters])Process incoming data, calling process_data, process_formdata as needed, and run filters.
process_data(value)Process the Python data applied to this field and store the result.
process_formdata(valuelist)Process data received over the wire from a form.
validate(form[, extra_validators])Validate this FieldList.
Attributes Documentation
- data¶
- do_not_call_in_templates = True¶
- errors = ()¶
- process_errors = ()¶
- raw_data = None¶
- validators = ()¶
- widget = <wtforms.widgets.core.ListWidget object>¶
Methods Documentation
- __call__(**kwargs)¶
Render this field as HTML, using keyword args as additional attributes.
This delegates rendering to
meta.render_fieldwhose default behavior is to call the field’s widget, passing any keyword arguments from this call along to the widget.In all of the WTForms HTML widgets, keyword arguments are turned to HTML attributes, though in theory a widget is free to do anything it wants with the supplied keyword arguments, and widgets don’t have to even do anything related to HTML.
- append_entry(data=<unset value>)[source]¶
Create a new entry with optional default data.
Entries added in this way will not receive formdata however, and can only receive object data.
- classmethod check_validators(validators)¶
- gettext(string)¶
Get a translation for the given message.
This proxies for the internal translations object.
- Parameters:
string – A string to be translated.
- Returns:
A string which is the translated output.
- ngettext(singular, plural, n)¶
Get a translation for a message which can be pluralized.
- Parameters:
singular (str) – The singular form of the message.
plural (str) – The plural form of the message.
n (int) – The number of elements this message is referring to
- populate_obj(obj, name)[source]¶
Populates obj.<name> with the field’s data.
- Note:
This is a destructive operation. If obj.<name> already exists, it will be overridden. Use with caution.
- post_validate(form, validation_stopped)¶
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.
- pre_validate(form)¶
Override if you need field-level validation. Runs before any other validators.
- Parameters:
form – The form the field belongs to.
- process(formdata, data=<unset value>, extra_filters=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.
- process_data(value)¶
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)¶
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.