Hi
I’ve been playing with Yii-1 back in the days. Then I had a break for long time. And now trying to write simple CRUD app with Yii-2.
My problem is to display value from relation in view. I’ve searched forums and haven’t found solution.
I have a model and relation defined in it to access data from another table.
In Yii-1 I was accessing the relation data
array(
'name'=>'id_manager_type',
'header'=>'Manager Type',
'value'=>'$data->rel_id_manager_type->name_en',
),
Where rel_id_manager_type was relation defined in master model. And name_en was column name in related table.
In Yii-2 I am trying to access relation data:
[
'attribute'=>'Business Type',
'format'=>'raw',
'value' => Html::encode($data->businessTypes->name_en),
],
But it returns
Undefined variable: data
What am I doing wrong?