FormField¶
- class bootlace.forms.fields.FormField(*args, **kwargs)[source]¶
Bases:
FieldEncapsulate a form as a field in another form.
- Parameters:
form_class – A subclass of Form that will be encapsulated.
separator – A string which will be suffixed to this field’s name to create the prefix to enclosed fields. The default is fine for most uses.
Attributes Summary
Built-in immutable sequence.
Methods Summary
__call__(**kwargs)Render this field as HTML, using keyword args as additional attributes.
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.
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])Validates the field and returns True or False.
Attributes Documentation
- data¶
- do_not_call_in_templates = True¶
- errors¶
- process_errors = ()¶
- raw_data = None¶
- validators = ()¶
- widget = <wtforms.widgets.core.TableWidget 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.
- 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.
- validate(form, extra_validators=())[source]¶
Validates the field and returns True or False. self.errors will contain any errors raised during validation. This is usually only called by Form.validate.
Subfields shouldn’t override this, but rather override either pre_validate, post_validate or both, depending on needs.
- Parameters:
form – The form the field belongs to.
extra_validators – A sequence of extra validators to run.