CGridView not allowing custom title value.

I have an annoying problem with CGridView in that it won’t accept my custom name for the field header. In the example below I am trying to have the column header print ‘Is paid’. However this is causing an exception with the message ‘Is paid’ is not defined. If I change it back to the MySQL column name ‘expensePaid’ it works OK.

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










         array('name'=>'Is paid', 'value'=>'Expense::getStatusText($data["expensePaid"])'),






 )); ?>

I have used this is the past and it’s work as expected. Is there cases where this approach will not work?

This is with Yii version 1.1.10.


See here:




         array('header'=>'Is paid', 'value'=>'Expense::getStatusText($data["expensePaid"])'),

Thanks for the response.

This did work. However I’m confused why is some instances I can use name and other times I have to use header.

As far as I know, you can use ‘name’ in camelCase even if it is not an attribute of the model. However, if that’s the case, you must provide a ‘value’, and you won’t be able to sort by that column, obviously.