Display department name instead of department id

Hi Guys,

I am new to Yii. I have just downloaded and it’s really cool. I have setup a new webapp using yii called logonapp by following the tutorial here

after done setting up, I went to

http://localhost:8888/logonapp/index.php/employee/

and it showing a list of employee. I wanted to change department to display name instead of id. Can anyone tell me how to change this please? thanks in advance!

regards,

Mark Thien

The CListView field specification should be changed to department.name (assuming the relationship was named department and the desired attribute of the department model is name)

For more reading about relational AR visit the guide

/Tommy

@Mark Thien

Please do not post same questions on new threads… .you already posted the same question… and got some answers here - http://www.yiiframework.com/forum/index.php?/topic/14725-

If you need to add more information you can add to the original post instead of creating new post

I am sorry i really don’t know as my post was being moved

Hi tri,

I do not understand, below are the code and how should I change it?


<?php

$this->breadcrumbs=array(

	'Employees',

);


$this->menu=array(

	array('label'=>'Create Employee', 'url'=>array('create')),

	array('label'=>'Manage Employee', 'url'=>array('admin')),

);

?>


<h1>Employees</h1>


<?php $this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_view',

)); ?>

regards,

Mark

Sorry i was wrong, the format should be $data->department->name, still assuming the relationship in Employee model was named department and the desired attribute of the department model is name (I don’t have Larry Ullmans code example at hand). Of course I’m talking about list view field definitions in the file _view.php

/Tommy