F
F
Flower Genius2018-05-04 10:06:37
Yii
Flower Genius, 2018-05-04 10:06:37

How to make the select parameter empty initially?

I use the search Model for searching. In order not to write the category for the search by hand, I did it like this.

<?= $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(Category::find()->all(), 'id','name'),['style'=>'font-family: \'Exo 2\', sans-serif; color: #0f0f0f; font-size:17px'])->label('Отделение')?>

But the bottom line is that the first branch of the list is always active. That is, it will already search by this parameter. But how to make it so that the parameter was not there initially?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arman, 2018-05-04
@dunakov1212

<?= $form->field($model, 'category_id')->dropDownList(['' => 'Укажите отделение'] + ArrayHelper::map(Category::find()->all(), 'id','name'),['style'=>'font-family: \'Exo 2\', sans-serif; color: #0f0f0f; font-size:17px'])->label('Отделение')?>

I
Ilya Beloborodov, 2018-05-04
@kowap

https://stackoverflow.com/questions/17060177/yii2-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question