CGridview and 1-to-1 relationship

Hi guys,

I jsut started learning Yii for last few days and I stuck on this problem.

Relationships are as follows:

Brokerage has many Agents and an agent belongs to a brokerage

An Agent belongs to A person and a person has one agent.




 $dataProvider = new CArrayDataProvider($data=$model->agents, $config);

	$this->widget('zii.widgets.grid.CGridView', array(

		'dataProvider'=>$dataProvider,

		'columns'=>array(

			array(

				'name' => 'First Name',

				'value' => '$data->person->first_name',

			),

			array( 

				//display a column with "view", "update" and "delete" buttons

				'class'=>'CButtonColumn',

			),

		)

	));



I got the error -> Property "Agent.id" is not defined.

If I run the code below,




     $agents = $model->agents;

	foreach($agents as $agent)

	{

		var_dump($agent->person->first_name);

		var_dump($agent->person->last_name);

		var_dump($agent->person->email);

		var_dump($agent->person->home_phone);

		var_dump($agent->person->mobile_phone);

	}



I got what i want without error. Why the CGridView give me [Property "Agent.id" is not defined] error ?

Thanks

Note that you posted in the Yii 1.0.x sub-forum… this version of Yii is not maintained anymore… .and I presume you started to learn the latest version… not this one :D

opps, thx for letting me know.