Yii2 Gridview Foreign Key

/ Published in: PHP
Save to your folder(s)

The 1stline in the function that generates the Foreign key relation in the model, 2nd is the name of the attribute in the gridview

Copy this code and paste it in your HTML
  1. public function getLab() { return $this->hasOne(Lab::className(), ['id' => 'id_lab'] );}
  2. 'lab.name_lab',

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.