Answer the question
In order to leave comments, you need to log in
Outputting value in Yii2 dropDownList from related tables?
Good day to all! Please help.
There is a table to which an entry is made:
--client_equipment
--->client_lk_id
In the client_lk_id field, an id from the table is passed:
--client_lk
--->id
--->client_id
--->name_lk_id
In turn, an id from tables:
--client
--->id
--->clien_name
id from the table is passed to name_lk_id:
--name_lk
--->id
--->name
In other words, there are clients, each client can have a personal account (and more than one), and equipment is connected to the personal account (also several). Clients are created, personal accounts are attached to them. We create equipment and link it to a personal account.
The question is how, when creating equipment , to display in dropDownList instead of name_lk_id / client_id the value of client_name / name from another table
<?= $form
->field($model, 'client_lk_id')
->dropDownList(
\yii\helpers\ArrayHelper::map(common\models\ClientLk::find()->all(), 'id', 'name_lk_id', 'client_id')
); ?>
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