I have a dropdown with multiple option enabled. I’m trying to preselect some its options using listOptions, but facing issues.
echo CHtml::activeDropDownList($profileChart, "[$type]box_id[$i][]", $planets, [
'multiple' => 'multiple',
])
and $plannets is generated using the following option
CHtml::listOptions([], CHtml::listData(Zodiac::model()->findAll(), "id", "name"), $htmlOptions)
It’s throwing the following exception.
Invalid argument supplied for foreach()
whereas listData option works perfectly fine, but I need listOptions so I can preselect multiple values.
I couldn’t find enough examples of using listOptions anywhere in the net. I believe the first param of listOptions is the array which I would like to preselect in the dropdown, but I’m trying to get it run without error first. Can anyone help me?