title: Yii2, how to use another model for display in view file
body: <p>I am sorry for my English. So, I have 3 tables with many to many relation.</p>
  
  <p>And this code which display attributes in view file:</p>
  
  <pre><code>    &lt;?= DetailView::widget([
      'model' =&gt; $model,
      'attributes' =&gt; [
          'scientist_id',
          'scientist_name',
          'scientist_surname',
          'scientist_patronymic',
          'scientist_birthdate',
          'scientist_email:email',
          'scientist_phone',
          'scientist_photo',
          'scientist_status',
          'scientist_job:ntext',
          'scientist_additional_information:ntext',
          'field_id', //display field but no data
      ],
  ]) ?&gt;
  </code></pre>
  
  <p>So I need to display in  " field_id's " which corresponding "scientist_id" from SUMMARY_FIELD table. And how can I do this?</p>
  
  <p><a href="https://i.stack.imgur.com/K7EIN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K7EIN.png" alt="scientst table and other"></a></p>
  
  <p>Relations with tables in Scientist model:</p>
  
  <pre><code>    public function getSummaryFields()
  {
      return $this-&gt;hasMany(SummaryField::className(), ['scientist_id' =&gt; 'scientist_id']);
  }
  public function getFields()
  {
      return $this-&gt;hasMany(Field::className(), ['field_id' =&gt; 'field_id'])-&gt;viaTable('summary_field', ['scientist_id' =&gt; 'scientist_id']);
  }
  </code></pre>
  
  <p>Relations in SummaryField model:</p>
  
  <pre><code>    public function getField()
  {
      return $this-&gt;hasOne(Field::className(), ['field_id' =&gt; 'field_id']);
  }
  
  /**
   * @return \yii\db\ActiveQuery
   */
  public function getScientist()
  {
      return $this-&gt;hasOne(Scientist::className(), ['scientist_id' =&gt; 'scientist_id']);
  }
  </code></pre>