User Tools

Site Tools

This is an old revision of the document!


Helper Field 'hidden'

Field 'hidden' is an invisible HTML input. As such, no screenshot possible :-)

PHP Code

'MYCONTROLLER_OPTION' => [
    'type'          => 'hidden',
    'required'      => true,
    'auto_value'    => true,
    'default'       => 0,
    'cast'          => 'intval',
    'validation'    => 'isInt',
    'empty'         => false,
]

Parameter Description

'type'

Always 'hidden' for this type of field. Mandatory.

'required'

Setting it to true makes sure that the entire submitted data gets stored only if there's valid data in this field. Defaults to false.

'auto_value'

Whether Helper should grab the currently set value for the configuration option automatically from POST request parameters, and if there is no such parameter, from the database. Supersedes 'value'. Defaults to true.

'defaultValue'

Value to use if 'auto_value' is unset or set to true, but neither a matching POST request parameter, nor a matching database entry is present. Defaults to an empty string.

'value'

Set HTML input value to this value. Requires 'auto_value' to be set to false. Defaults to an empty string.

Notably, as Option Fields are usually set in the class constructor, this value gets set before default procedures had a chance to process the incoming request. Accordingly, setting a value here should parse the request as needed while doing so. Else the shown value is always one version behind.

Parameters for Submit

The following parameters describe how submitted field values is dealt with. Ignored if data isn't going to be stored in the database.

'required'

(see above)

'default'

Default value to get stored in the database, in case the submitted field is empty. Optional.

'cast'

Name of a PHP casting function to convert the submitted value with. Can be boolval, floatval or intval. Default is to store a string.

'validation'

Name of a method in class Validate to check the submitted field value against. Optional.

'empty'

Set to true, if an empty field should also pass validation. Optional.

HTML Output

Ignoring whitespace, one gets this HTML:

<input type="hidden" name="MYCONTROLLER_OPTION" value="123">

Yes, that's all. It doesn't even get a DIV class=“form-group” wrapper.

helper_field_hidden.1545508392.txt.gz · Last modified: 2018/12/22 20:53 by Traumflug