Hi Guys!
Just for understanding:
Is is possible to add a default value to the "prompt" of a DropDownList?
If yes - what is the correct way?
For example I have:
echo Html::dropDownList(
'myDropDown',
null,
[
1 => 'Item 1',
2 => 'Item 2',
3 => 'Item 3',
],
['prompt' => 'Select Item']
);
I tried for example:
echo Html::dropDownList(
'myDropDown',
null,
[
1 => 'Item 1',
2 => 'Item 2',
3 => 'Item 3',
],
[
'prompt' => [
'label' => 'Select Category',
'value' => 'promtValue'
]
]
);
But prompt seems to accept only a string?
Is there a way to add a default value to a prompt?
Or do I have to do something like:
echo Html::dropDownList(
'myDropDown',
null,
array_merge(
['promtValue' => 'please select'],
[
1 => 'Item 1',
2 => 'Item 2',
3 => 'Item 3',
]
)
);
What is the proposed "correct" way?
Thanks and best regards