S
S
Sergey Beloventsev2016-04-26 23:08:08
Yii
Sergey Beloventsev, 2016-04-26 23:08:08

How to add a drop down list?

There is a drop down list

<?= $form->field($catSerial, 'id_cat')->dropDownList($cat,['prompt' => 'Выбирите категорию']); ?>

there was a need to implement the ability to add the same lists, as follows:
By clicking on any link (let's say id="dropbox"), a new drop-down list is created;
This is necessary so that the page can be displayed in two or more categories;
Specifically, this drop-down list displays the number of categories from the database.
Please tell me how to implement this correctly in Yii2.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Arutyunov, 2016-04-27
@arutyunov

Install the Select2 widget from kartik-v.
It allows multiple selections in a drop down list.
And in addition, a public property must be added to the model in order to process the preservation of the many-to-many relationship.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question