CDetailView & enum field


I have a column in database table where column type is enum - enum(‘Y’, ‘N’). I print out table row’s using zii.widgets.CDetailView. This prints out Y or N depends on column value, but i want Yii converts Y to Yes and N to No.

Whats the best way to do it?

Thank You!

'value'=>$model->fieldname=='Y' ? 'Yes':'No',

… or something like that should work :)

Thank You!

bettor logic works. just in case to another beginners, heres full code how it should look like:

'active' => array('label' => 'Active', 'value'=> ($model->active=='Y' ? 'Yes':'No') ),

if you add value in array then you should add label also. otherwise label field is empty.

Very nice Bulldoze,

but let me ask, if you have to calculate the value, for example, suppose there is several values, not just two: yes and no, let me explain better, the value can be five letters. Another example, suppose you have to calculte the cost, which is an ecuation cost = price * quantity, and price and quantity are model’s attributes. Can you built a function, like cGridView ?