Question

I have a table called City, table contain field IsMetro it is bit(1), so it can store 1 or 0, i have generated model for this table and generated CRUD operation forms.

Now i want True instead of 1 and False instead of 0.

Where should i perform this operation in CActiveDataProvider or CGridView and how to do this

i am getting this output

CityId - City Name - IsMetro-(bit(1))
1        A           1

i want this output

CityId - City Name - IsMetro-(bit(1))
1        A           True
Was it helpful?

Solution

Try this code:

In views admin.php

array(
    'name'=>'IsMetro',
    'value'=>'$data->IsMetro=="1"?"TRUE":"FALSE"',
      ),

OTHER TIPS

You can do this in CGridView column by using the property value. In you column you can write like this

 array(

            'header' => 'IsMetro',
            'htmlOptions' => array('style' => 'text-align:center;'),
            'value'=>'($data->IsMetro==1)?"True":"False"',
        ),
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top