H
H
hollanditkzn2017-03-21 10:26:25
Yii
hollanditkzn, 2017-03-21 10:26:25

How to remove an extra entry in the dropdown list?

I made a dropdown list
<?= $form->field($model, 'id_product')->dropDownList([
ArrayHelper::map(Tovar::find()->all(), 'id', 'name')
],
[
'prompt' => 'Select a product',
]) ?>
And it looks like this
0
entry1
entry2
0 will be redundant, since id 0 is entry1, how to fix this bug?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-03-21
@hollanditkzn

0 - because the array is extra slapped. Do it like this:

<?= $form->field($model, 'id_tovar')->dropDownList(
ArrayHelper::map(Tovar::find()->all(), 'id', 'name'),
['prompt' => 'Выберите товар',]
) ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question