There are two tables without keys. For each created a model (Order and Manager). For Order, created crud gridview and in its model I wrote the following

public function getManager(){ return $this->hasMany(Manager::className(), ['order_managerId' => 'manager_id']); } 

where order_managerId is a column from the table in which this function is registered, and manager_id is a column from the second table. I want to remove manager_firstName from the second table instead of id. The question is, am I doing the right thing? I tried several options while I get an error.

UPD. Changed to

 public function getManager(){ return $this->hasOne(Manager::className(), ['manager_id' => 'order_managerId']); } 

It all worked

    1 answer 1

    Yes, you get a relation between the models, in order to display the value from the associated model in the gridview, just point the necessary attribute through a point, I did not test it, but logically, see the link

      'columns' => [ [ 'attribute' => 'manager', 'value' => 'manager.manager_firstName' ], //или так: 'manager.manager_firstName', 

    http://www.yiiframework.com/wiki/653/displaying-sorting-and-filtering-model-relations-on-a-gridview/