7.5.2 NameRecorderMixin

##
7.5.2 NameRecorderMixin

The `NameRecorderMixin` class writes the names of all input fields in a form to a hidden field named `__albform__` at the end of the form.

When the browser submits a form with this field the application `merge_request()` method calls the `merge_request()` method of this class to merge the browser request into `ctx.locals`.

`__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 `FieldTypeError` exception.

  Input field types `radio`, `image`, and `submit` are implicitly flagged to return a list of values.

`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.