I am trying to use a CListView to display data from a table in my database, however when I come to access relational data (such as $data->type->Name), I get the error: Trying to get property of non-object.
I have used the same syntax elsewhere, so I know the database is OK, just having issues with this widget!
Aaaargh, that’s it! I had some “holes” in my data, some records didn’t had the heads-id set. For these records the relation form Department to Employee was not defined. So I did:
if (!empty($data->head))
echo CHtml::encode($data->head->lastName);
else
echo 'n.n.';