Cake\View\Helper\FormHelper::multiCheckbox PHP Method

multiCheckbox() public method

### Options - escape - If true contents of options will be HTML entity encoded. Defaults to true. - val The selected value of the input. - class - When using multiple = checkbox the class name to apply to the divs. Defaults to 'checkbox'. - disabled - Control the disabled attribute. When creating checkboxes, true will disable all checkboxes. You can also set disabled to a list of values you want to disable when creating checkboxes. - hiddenField - Set to false to remove the hidden field that ensures a value is always submitted. Can be used in place of a select box with the multiple attribute.
See also: Cake\View\Helper\FormHelper::select() for supported option formats.
public multiCheckbox ( string $fieldName, array | Traversable $options, array $attributes = [] ) : string
$fieldName string Name attribute of the SELECT
$options array | Traversable Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the checkboxes element.
$attributes array The HTML attributes of the select element.
return string Formatted SELECT element
    public function multiCheckbox($fieldName, $options, array $attributes = [])
    {
        $attributes += ['disabled' => null, 'escape' => true, 'hiddenField' => true, 'secure' => true];
        $attributes = $this->_initInputField($fieldName, $attributes);
        $attributes['options'] = $options;
        $attributes['idPrefix'] = $this->_idPrefix;
        $hidden = '';
        if ($attributes['hiddenField']) {
            $hiddenAttributes = ['name' => $attributes['name'], 'value' => '', 'secure' => false, 'disabled' => $attributes['disabled'] === true || $attributes['disabled'] === 'disabled'];
            $hidden = $this->hidden($fieldName, $hiddenAttributes);
        }
        return $hidden . $this->widget('multicheckbox', $attributes);
    }