Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to format a column as currency in GridView(yii)?

Hello everyone and thanks for reading . I was wondering how i could format a number into a currency or just simply attach € at the end. I am working in a gridview on the admin page in the yii framework. i have this as eg

'columns'=>array(
        'title',
            array(
                'name'=>'cost',
                'value'=>'$data->cost',
            )
like image 369
Gunnit Avatar asked Dec 20 '22 05:12

Gunnit


1 Answers

The Yii way would be to use Yii's existing currency formatter, like this:

array(
      'name'=>'cost',
      'value'=>'Yii::app()->numberFormatter->formatCurrency($data->cost, "EUR")',
     )
like image 86
adamors Avatar answered Jan 16 '23 19:01

adamors