Want to display names instead of id

Happy Day… to All

    I was Very new to Yii framework, I just started to learn and it was very interesting,  and with reference of Agile book  I have started a sample project, [i]I don’t know how to display names instead of id  in manage I can change in view but not in manage ., Please any one help me.



The view and manage view have the same controller/model (ProjectInfo if I look at the screenshots) right?

Then it normally should work cause you are using in both views the ProjectInfo Model and Controller. so the important part, the relations, are for both views the same.

What have you tried to display the name instead of the id?

Post your relations of the involved models and relevant parts of the views here so we could better understand what’s your problem.


Thanks for replying ., i have attached the related files ., can you plz view the file and tell me what mistake i have done…


Hello all,

For the past one week i was trying to solve this… but nothing works…Plz any one help me to solve this…

It does not appear that you attached the view file for the "manage" view you are struggling with.

However, assuming you are using passing a CActiveDataProvider to a CGridView for display, you can specify the columns attribute to display different values. This is similar to what you have done in the specification of the attributes property for the CDetailView.

So, in your manage view…

$this->widget('zii.widgets.grid.CGridView', array(








You’ll have to do more work to get the searching on these values to behave as expected, but this might get you going in the right direction for the display of the data.

Thank You … So Much… It worked…

tried it but doesnt work for me.

here is my view.php

<?php $this->widget('bootstrap.widgets.TbDetailView',array(












and here is my relations

public function relations()


		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(










then here is my admin.php

<?php $this->widget('bootstrap.widgets.TbGridView',array(






















)); ?>

it says Trying to get property of non-object

can you help me with this?

I think you can simply use this in one line.

// format models resulting using listData

<?php echo $form->dropdownlist($model,‘user_id’, CHtml::listData(User::model()->findAll(),‘id’, ‘name’)); ?>