Jump to content
Larry Ullman's Book Forums

mcmurphy510

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by mcmurphy510

  1. Thanks Larry, Sorry for the reply delay. Other projects got in the way. I've been evaluating ZF2, Codeigniter and Yii for our SaaS app. So far, Yii looks like the winner. So I probably will be buying the book, but for now if you could post the code it would be much appreciated. Thanks again.
  2. Update: If I change the attributeLables() method in Department.php from: public function attributeLabels() { return array( 'id' => 'ID', 'name' => 'Name', ); } To: public function attributeLabels() { return array( 'id' => 'ID', 'name' => 'Department', ); } "Name" is now shown as "Department" I still do not have search on that column. Thanks.
  3. 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.
  4. Hi, I got all the way through the tutorial with no problems until the very end. In “EmployeeController.php” I’m trying to get yii to display the relation for department rather than the ID number. I have tried this code in the loadModel method: $model=Employee::model()->with('department')->findByPk((int)$id); I have double checked all of my relations and they all seem to be in order. It’s still showing the ID number rather than the department name. Any ideas? Thanks
×
×
  • Create New...