To the point, we’ve got this error notice right:
It comes from.., nah, this is my case, my erd is like this:
On Class relationships method I define the model with the following code:
class TheClass extends CActiveRecord
{
....
public function relations(){
return array( 'faculty' => array(self::BELONGS_TO, 'Fakulty', 'faculty_id') );
}
.......
}
On Class view, i tried to get the name of faculty with this code:
echo CHtml::encode($data->faculty_id->name);
and I’d got the error notice. I’d been trying many solution and finally.. the problem is solved, the right code is:
echo CHtml::encode($data->faculty->name);
Remember to use the relationship variable name that we’ve defined on the class model, not the attribute name.
Hopefully this simple solution can fix your problem too..
thank you …….helped
you’re welcome bro..
Great post.
Thanks