Dropdownlist with multiple select

Hi!

I am trying to create a dropdownlist that allows the user to select many options. I used the following on my view:

<?= $form->field($model, 'userGroup')->dropDownList($usersList, ['multiple' => true, 'selected' => true]) ?>

A select list does appear (bigger than usual), and I can select multiple users, but I have to keep the control key pressed to select more than one user, if I click on a user and then scroll to another user I want and click on it, the first user is deselected. Is this how the multiple select works here?

I have already searched in the forum but the dropdownlist is done as it is said it should be (unless Iā€™m getting it wrong).

Any help is appreciated.

Solved using kartik/Select2

I recently needed similar capabilities and ended up using

https://github.com/2amigos/yii2-multi-select-widget

just to give your another option.

1 Like