Answer the question
In order to leave comments, you need to log in
How to get drop down from related table?
In the forms generated by gii, you need to add a dropDownList into which data from the table linked via hasOne will enter. How to do it right? I found so far just creating a field as a separate widget, how else can I do it, but please at least with an example.
UPD:
So far done like this:
<?= $form->field($model, 'state_id')->dropDownList(\yii\helpers\ArrayHelper::map(\app\modules\admin\models\State::find()->all(), 'id', 'state')) ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question