It's possible to add attributes to a dropDownList's option tags using the 'options' element in $options, e.g.:
$form->field($model, 'foo')->dropDownList(['value1' => 'One', 'value2' => 'Two'], [
'options' => [
'value1' => ['disabled' => true],
'value2' => ['class' => 'bar']
],
'prompt' => 'please choose',
])
But it's not possible to add attributes to the option tag generated by 'prompt'. I'd like to do this:
$form->field($model, 'foo')->dropDownList(['value1' => 'One', 'value2' => 'Two'], [
'prompt' => 'please choose',
'promptOptions' => [
'class' => 'drop-down-prompt'
]
])
How about this syntax?
'prompt' => ['label' => 'Please Choose', 'class' => 'drop-down-prompt', 'value' => '-1'];
completely backwards compatible and won't add any new variables
@Faryshta, you seem to be right on this. How about a PR?
Most helpful comment
How about this syntax?
'prompt' => ['label' => 'Please Choose', 'class' => 'drop-down-prompt', 'value' => '-1'];completely backwards compatible and won't add any new variables