I would like to display the relations of a certain object in a grid view. Thus I edited the view.php of my class ‘Person’ (instance is $model) as follows:
And I can fix issue number 2 by setting the "header" property myself.
I think these fixes are just workarounds and not a clean solution. Any ideas how to use CGridView in this scenario without hacks??? Somehow CGridView refers to the outside $model instead of the models provided by CArrayDataProvider…
What is your controller called? Is it PersonController? because from CButtonColumn.php:
public $viewButtonUrl='Yii::app()->controller->createUrl("view",array("id"=>$data->primaryKey))';
public $updateButtonUrl='Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey))';
public $deleteButtonUrl='Yii::app()->controller->createUrl("delete",array("id"=>$data->primaryKey))';
So the best way is to do your first fix. For the second fix:
Go to your Address Model and change the attributes from there. change the array in attributeLabels method.
thanks for your reply. "attributeLabels()" is filled correctly on "Address". When I use the CGridView during the AddressController life cycle the values are translated fine. Thus I guess something breaks when it used during the PersonController life cycle.