Does anyone know how to display a conditional value in CGridView column field?
I've got an entry in the DB for gender 'M' of 'F', in die CGridView however I would like to display 'Male' and 'Female' respectively and not M or F.
Any ideas would be welcome ;-)
I have found that while full if/else syntax is not allowed, you can use the shorthand syntax. Something like this:
array(
'name'=>'column_name',
'type'=>'HTML',
'value'=>'($data->gender=="M")?"Male":"Female"',
),
I think you can do this with the "raw" type, as well as the "HTML" type.
Good luck!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.