Hello
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!
Page 1 of 1
CDetailView & enum field
#2
Posted 19 February 2012 - 04:51 AM
'value'=>$model->fieldname=='Y' ? 'Yes':'No',... or something like that should work
#3
Posted 19 February 2012 - 04:49 PM
Thank You!
bettor logic works. just in case to another beginners, heres full code how it should look like:
if you add value in array then you should add label also. otherwise label field is empty.
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.
#4
Posted 16 February 2013 - 03:51 PM
bulldoze, on 19 February 2012 - 04:49 PM, said:
Thank You!
bettor logic works. just in case to another beginners, heres full code how it should look like:
if you add value in array then you should add label also. otherwise label field is empty.
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 ?
Thanks
Share this topic:
Page 1 of 1

Help














