I’m experiencing a weird error during the rendering of a page which loads a Portlet.
"Trying to get property of non-object…"
The odd thing is, when I changed the relation name from ‘venueCity’ to anything else (e.g. ‘venuecity’, ‘loc’, ‘location’) I stopped getting the error… until after a certain amount of time, it breaks again.
It seems to be isolated to a certain type of object that I deal with… but it’s strange that, simply changing the name would cause it to work/break.
Model:
public function relations()
{
return array(
'venue' => array(self::BELONGS_TO, 'Venues', 'venue_id'),
'venueCity' => array(self::BELONGS_TO, 'Venues', 'venue_id',
'select'=>'city, geo_state_abbr'
),
);
}
Portlet:
protected function renderContent()
{
if(isset($this->parent)) {
$parent = $this->parent;
} else {
$parent = $this->getController()->loadParentModel();
}
if(!empty($parent->city)) {
$location = $parent->city . ', ' . $parent->geo_state_abbr;
} else {
$children = $parent->children;
$venue = $children[0]->venueCity;
$location = $venue->city . ', ' . $venue->geo_state_abbr; // ERROR HAPPENS HERE
}
$this->render('my-view',array(
'parent'=>$parent,
'location'=>$location,
));
}
I’m using Yii 1.1.7
Thoughts?