lengaltd
(lengaltd)
February 2, 2023, 8:29am
1
Hi Friends,
I hope we are doing fine.
I am facing some challenge on a dropdownlist where I select all option and save after opening for update nothing selected as shown on the attached image
on create
on create - I have selected option and save successfully
on update
Kindly assist me
I guess you are using Select2 which accepts array for selection. For update default selection $model->sponsors = [array of selection]
.
1 Like
lengaltd
(lengaltd)
February 2, 2023, 12:53pm
3
InsaneSkull:
$model->sponsors
Hi,
Thanks for your prompt response.
No I wasn’t using select2
Here is the code
<?= $form->field($model, 'sponsor_id')
->dropDownList(ArrayHelper::map($sponsors, 'user_id', 'user.name'), [ 'prompt' => 'Select Sponsor', 'class' => 'max-length form-control', 'multiple' => true ])
->label('Select Sponsor'); ?>
If select to will work let me try
I suggest to try Kartik Select2 , I believe array will be the same for default selection on normal drop-down.
1 Like