Thanks for the reply Larry. Here are my relations: From Employee.php:
'department' => array(self::BELONGS_TO, 'Department', 'departmentId')
From Department.php:
'employees' => array(self::HAS_MANY, 'Employee', 'departmentId')
It looks like my problem was in the view code. For employee/admin.php I had:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'employee-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'departmentId',
'firstName',
'lastName',
'email',
'ext',
array(
'class'=>'CButtonColumn',
),
),
));
Which I have replaced with:
...
'columns'=>array(
'id',
'department.name',
...
Is this the best way of going about this?
It is now showing the department name, but it's showing the column name as "Name" rather than Department and search functionality is also gone for that column.
Here's a screen cap of what it's doing:
Thanks again.