7.5.2 NameRecorderMixin

The NameRecorderMixin class records details of all input fields used by a form. When the form element is closed, a hidden field named __albform__ containing these details is added to the form.

When processing a request, the merge_request() method only merges fields with ctx.locals when they match the details found in the submitted __albform__ field.

__init__( )
When you inherit from the NameRecorderMixin class you must call the constructor.

form_open( )
Called when the <al-form> tag is opened.

form_close( )
Called just before the <al-form> tag is closed. A hidden field named __albform__ is written to the output.

input_add( itype, name [, value = None] [, return_list = 0])
Called when an <al-input> tag is executed. The itype argument contains the type attribute from the input tag, name contains the name tag attribute, and value contains the value of the input field if it is known and relevant. The return_list argument indicates the presence of the list attribute on the input tag.

As fields are added to each form the value of the return_list argument is checked against any previous setting of the argument for the same field name. The argument value is also checked against whether or not there are multiple instances of the field name. An detected discrepancy between the argument value and actual fields will raise a ApplicationError exception.

merge_request( )
Retrieves the __albform__ value from the browser request decodes it and then merges the browser request into the local namespace accordingly.

If an input field has been flagged to return a list (via the list tag attribute) then the method will create a list in ctx.locals for the field regardless of the number of values sent by the browser. An empty list is created when the field is missing from the browser request.

Request fields not listed in __albform__ are ignored.