CGridView columns value does not work as expected


I am newbie at yii. I would be thankful if someone could help me.

I am trying to change CGridView column’s value:

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








                    'name' => 'fruit',

                    'filter'=> array("1" => 'Apple', "2" => 'Banana'),

                    'value' => (('$data->fruit'=="1")?"Apple":"Banana")




Problem is that it still shows me number 1 or 2… (while filter is working)

Try this

'value' => '(($data->fruit=="1")?"Apple":"Banana")'

or simpified

'value' => '$data->fruit=="1"?"Apple":"Banana"'


tri is right, value is an 'eval’uated expression, so it must be a string

I know I’m right about the string, but that doesn’t mean it will fix all his problems whatsoever. We’ll have to wait for reported results. <_<


Thank you guys, you were right. Both variants worked for me.

Thank you!