How to set prompt value for dropdownlist in Yii 2?

0 like 0 dislike
327 views
How to specify its value for a value prompt in the drop-down list:

<?= $form->field($model, 'table_id')->label(")->dropdownList( Table::find()->select(['row_name', 'id'])->indexBy('id')->column(), ['prompt' =>'Prompt', 'class'=>", 'id'=>", 'options' => [ 4 => ['data-image' => ", 'data-html-text'=>"], 6 => ['data-image' => ", 'data-html-text'=>"], 9 => ['data-image' => ", 'data-html-text'=>"], ] ]); ?>


The actual 'prompt' =>'Prompt',
Returns in html
Prompt

Have not found a way how to prompt to ask for value.
by | 327 views

1 Answer

0 like 0 dislike
You've asked your options and if you want to set the attribute data-*, it is
[ 'prompt' => 'Select', 'data' => [ 'text' => 'Text', 'image' => 'Image' ] ]

or a little easier
[ 'prompt' => 'Select', 'data-text' => 'Text', 'data-image' => 'Image' ]

Well, for prompt you can use the array
'prompt' => [ 'text' => 'Select', 'options' => [ 'value' => 'prompt', 'class' => 'prompt-class', 'selected' => 'selected' ] ]


In the documentation everything is painted
by

Related questions

0 like 0 dislike
2 answers
asked May 20, 2019 by Silverviql
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
asked Apr 14, 2019 by evgen9586
110,608 questions
257,186 answers
0 comments
33,546 users