Answer the question
In order to leave comments, you need to log in
Yii2 - why aren't default values set for dropDownList?
Here is a part of the form
<?= $form->field($model, 'categories[]')->dropDownList(Category::getCategoryList(), [
'multiple' => true,
'options' => $movie->getCategorySelected(),
]
) ?>
array(2) { [5]=> array(1) { ["selected"]=> bool(true) } [27]=> array(1) { ["selected"]=> bool(true) } }
Answer the question
In order to leave comments, you need to log in
well also look that is deduced and that is expected.
array('options'=> , 'prompt' => )
is expected
and you load
array(5=>, 27=>)
there I think you need to use the following code www.yiiframework.com/doc-2.0/yii -helpers-basehtml.... ()-detail
'options'=> [ 'options'=>$movie->getCategorySelected()
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question