Answer the question
In order to leave comments, you need to log in
How to set value for prompt dropdownlist in Yii2?
How to set your own value for the prompt value in the dropdown list:
<?= $form->field($model, 'table_id')->label('')->dropdownList(
Table::find()->select(['row_name', 'id'])->indexBy('id')->column(),
['prompt' =>'Промпт', 'class'=>'', 'id'=>'', 'options' => [
4 => ['data-image' => '', 'data-html-text'=>''],
6 => ['data-image' => '', 'data-html-text'=>''],
9 => ['data-image' => '', 'data-html-text'=>''],
] ]);
?>
'prompt' =>'Промпт',
<option value="">Промпт</option>
Answer the question
In order to leave comments, you need to log in
You have already set options and if you want to set the data-* attribute, then it is done like this
[
'prompt' => 'Select',
'data' => [
'text' => 'Text',
'image' => 'Image'
]
]
[
'prompt' => 'Select',
'data-text' => 'Text',
'data-image' => 'Image'
]
'prompt' => [
'text' => 'Select',
'options' => [
'value' => 'prompt',
'class' => 'prompt-class',
'selected' => 'selected'
]
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question