Fields From Other Models in Admin Page

Dear Yii Users,

I have tried multiple solution but still failed to overcome the issue.

There are currently User’s and Biodata table I created. As per normal, I am using ID from User table that relates to data User_ID in Biodata table.

In User CGridView, I would like to display data from both tables in Admin page. I have tried the code below but it returned an error below:

Trying to get property of non-object




array(

			'header'=>'full_name',

			'value'=> 'Biodata::model()->FindByPk($data->user_id)->full_name',

		),



Am I missing steps along the way? Will the output be searchable?

Thank you. :(

Are the models related? If so, try this: http://stackoverflow.com/questions/6057105/yii-relational-datagrid-widget

Related? Nope, not that I know of as I have not edit the models/controllers as of now.

Thank you.

I have managed to edit the relation for the two tables. Also, I have noticed that I did not set the proper FK in place, unfortunately. With that rectified, I have managed to retrieve other data from other models.




	public function relations()

	{

        $relations = Yii::app()->getModule('user')->relations;

        if (!isset($relations['profile']))

            $relations['profile'] = array(self::HAS_ONE, 'Profile', 'user_id');

	    $relations['biodata'] = array(self::HAS_ONE, 'Biodata', 'user_id');

        return $relations;

	}