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