dropDownList() public static method
Generates a drop-down list.
public static string dropDownList ( $name, $selection = null, $items = [], $options = [] ) | ||
---|---|---|
$name | string |
The input name |
$selection | string|array|null |
The selected value(s). String for single or array for multiple selection(s). |
$items | array |
The option data items. The array keys are option values, and the array values are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, an option group will be generated whose label is the key associated with the sub-array. If you have a list of data models, you may convert them into the format described above using yii\helpers\ArrayHelper::map(). Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in the labels will also be HTML-encoded. |
$options | array |
The tag options in terms of name-value pairs. The following options are specially handled:
The rest of the options will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using encode(). If a value is null, the corresponding attribute will not be rendered. See renderTagAttributes() for details on how attributes are being rendered. |
return | string |
The generated drop-down list tag |
Please login to continue.