I have 3 tables with a many-to-many connection. Here is the code that is responsible for displaying in the view file:

<?= DetailView::widget([ 'model' => $model, 'attributes' => [ 'scientist_id', 'scientist_name', 'scientist_surname', 'scientist_patronymic', 'scientist_additional_information:ntext', 'field_id', //отображает поле, но не соответствующие айдишники ], ]) ?> 

I need to display in the viewfile the corresponding field_id to scientist_id from the table (class / model) Summary_field. How to do it?

scientst table and other

    1 answer 1

    Just point through

     <?= DetailView::widget([ 'model' => $model, 'attributes' => [ 'scientist_id', 'scientist_name', 'scientist_surname', 'scientist_patronymic', 'scientist_additional_information:ntext', 'Summary_field.field_id', //где Summary_field название связи в моделе ], ]) ?> 

    Or use an ananim function, where you can return everything you see fit, you can use the link, you can use another function

     <?= DetailView::widget([ 'model' => $model, 'attributes' => [ 'scientist_id', 'scientist_name', 'scientist_surname', 'scientist_patronymic', 'scientist_additional_information:ntext', [ 'attribute'=>'field_id', 'content'=>function($model){ return $model->summary_field->field_id //где Summary_field название связи в моделе } ] ], ]) ?>