We have the Categories table with columns:
id
parent_id
title
Also we have the relation:
public function relations()
{
return array(
'Parent' => array(self::BELONGS_TO, 'Categories', 'parent_id'),
);
}
We use the function:
public function getFullCategory()
{
$showparentname = 'Parent.title';
return $this->$showparentname.' - '.$this->title;
}
The form dropDownList use:
$categories = Categories::model()->findAll();
$categories_list = CHtml::listData($categories, 'id', 'FullCategory');
But it doesn’t work
Property "Categories.Parent.title" is not defined.