conditional statements inside of 'value' for CDataColumn

后端 未结 1 716
陌清茗
陌清茗 2021-01-23 06:31

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

相关标签:
1条回答
  • 2021-01-23 06:49

    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!

    0 讨论(0)
提交回复
热议问题