There’s, of course, a “Yii way” of handling that issue. First of all you got to make sure you have a defined a relationship with the Department model in your Employee model.
It should be something like this:
// protected/models/Employee
public function relations() {
return array(
'department' => array(self::BELONGS_TO, 'Department', 'departmentId'),
);
}
Now you can access the department from your employee view easily doing the following: