Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question