Format column in CGridview

This may sound like a silly question - if it is I apologise in advance!

I am trying to format a column in CGridview with 2 decimal places.


                    'name'=>'Value in GBP',




This displays as integer. How can I pass the second parameter (decimals) to get it to display to 2 decimal places?

GBPBalance? ‘$data->GBPBalance(2)’

value is 'eval’uated

Please be more specific - what is the exact syntax?

I see that the following works - not sure it was what you were saying:


                    'name'=>'Value in GBP',


                   // 'type'=>'number',




What I said is that value is using the ‘eval’ PHP function and will work with any correct PHP code. $data works because it is passed to the function, so you need to be very careful of what you include in there.

I thought that GBPBalance was a function not an attribute, and I suggested to pass the number of decimals to the function so you return the attribute with a number_format function. Your solution is correct.


Many thanks for your help Antonio - sometimes the simplest things take the longest to figure out with a framework as powerful as yii. I love it!

Yeah… and no matter how long you are with it, you maintain that wonderful learning curve full of surprises. And when you think you know enough, the dev team comes with better features…

btw: always check its internal code, those small things will be easy figured out