protected static activeListInput ( string $type, |
||
$type | string | the input type. This can be 'listBox', 'radioList', or 'checkBoxList'. |
$model | the model object | |
$attribute | string | the attribute name or expression. See [[getAttributeName()]] for the format about attribute expression. |
$items | array | the data item used to generate the input fields. The array keys are the input values, and the array values are the corresponding labels. Note that the labels will NOT be HTML-encoded, while the values will. |
$options | array | options (name => config) for the input list. The supported special options depend on the input type specified by `$type`. |
return | string | the generated input list |
protected static function activeListInput($type, $model, $attribute, $items, $options = [])
{
$name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
$selection = isset($options['value']) ? $options['value'] : static::getAttributeValue($model, $attribute);
if (!array_key_exists('unselect', $options)) {
$options['unselect'] = '';
}
if (!array_key_exists('id', $options)) {
$options['id'] = static::getInputId($model, $attribute);
}
return static::$type($name, $selection, $items, $options);
}