markthien
(Markthien)
January 3, 2011, 3:57pm
1
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
This is the fifth post in my series on Yii, my favorite PHP framework. , I show how to download and test the framework itself. , I show how to create a basic Web application., I walk through some c…
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
tri
(tri - Tommy Riboe)
January 3, 2011, 4:58pm
2
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
mdomba
(Maurizio Domba Cerin)
January 3, 2011, 8:38pm
3
@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
markthien
(Markthien)
January 4, 2011, 3:10am
4
mdomba:
@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
markthien
(Markthien)
January 4, 2011, 3:20am
5
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
tri:
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
tri
(tri - Tommy Riboe)
January 4, 2011, 5:55pm
6
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