I have select HTML tag generated by this code:
<?= $form->field($model, 'something')->dropDownList(Class::method(), ['prompt' => Yii::t('app', '--- Choose ---')]) ?>
I would need to add an HTML attribute (e.g. inline style) to each option tag.
Can you give me a hint, please?
Advertisement
Answer
You can use options
<?= $form->field($model, 'something')->dropDownList(Class::method(), ['prompt' => Yii::t('app', '--- Choose ---'), 'options' => ['value1' => ['style' => 'color:red;'],]]) ?>