/** * Renders a list of checkboxes. * A checkbox list allows multiple selection, like [[listBox()]]. * As a result, the corresponding submitted value is an array. * The selection of the checkbox list is taken from the value of the model attribute. * @param array $items the data item used to generate the checkboxes. * The array values are the labels, while the array keys are the corresponding checkbox values. * Note that the labels will NOT be HTML-encoded, while the values will. * @param array $options options (name => config) for the checkbox list. The following options are specially handled: * * - unselect: string, the value that should be submitted when none of the checkboxes is selected. * By setting this option, a hidden input will be generated. * - separator: string, the HTML code that separates items. * - item: callable, a callback that can be used to customize the generation of the HTML code * corresponding to a single item in $items. The signature of this callback must be: * * ~~~ * function ($index, $label, $name, $checked, $value) * ~~~ * * where $index is the zero-based index of the checkbox in the whole list; $label * is the label for the checkbox; and $name, $value and $checked represent the name, * value and the checked status of the checkbox input. * @return static the field object itself */ public function checkboxList($items, $options = []) { $this->adjustLabelFor($options); $this->parts['{input}'] = Html::activeCheckboxList($this->model, $this->attribute, $items, $options); return $this; }