M
M
Monitorkin2016-02-11 15:29:33
Yii
Monitorkin, 2016-02-11 15:29:33

Yii2 How to set value from base to dropDownList?

in the form _form.php there is a field dropDownList :

<?= $form->field($model, 'status')->dropDownList([ 'Ок' => 'Ок', 'Не ок' => 'Не ок' ]) ?>

when the form is loaded, the field is set to an empty value, even if there is another value in the database.
How to make it so that by default the set value from the database is automatically loaded into the field?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Artemiev, 2016-02-11
@Monitorkin

dropDownList(ArrayHelper::map({Model}::find()->all(), 'field for attribute val', 'field for content of option tag') )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question