I need assistance on drop down list

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


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