dimis283
(Dimis283)
1
I am using the CGridView to view the cats table and I have an array $acts(1=>‘active’,0=>‘unactive’).
So I set this but it does not work, what is wrong? (cat_active has values 1,0 )
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'cat_tittle',
array('name'=>'cat_active','value'=>$acts[$data->cat_active]),
array(
'class'=>'application.components.ButtonColumn',
),
),
));
bettor
(Live Webscore)
2
try this:
array('name'=>'cat_active','value'=>'$acts[$data->cat_active]'),
[not tested]
dimis283
(Dimis283)
3
Now nothing is shown at this attr , I thing because I use an array.
When I set $acts[1] I see the ‘active’ , something is wrong with $data->cat_active
mdomba
(Maurizio Domba Cerin)
4
I solved similar problem with a function…
before calling CGridView make a function like:
function getStatus($id)
{
$acts(1=>'active',0=>'unactive');
return $acts[$id];
}
then in the call to CGridView use:
...
'cat_tittle',
array('name'=>'cat_active','value'=>'getStatus($data->cat_active)'),
...
dimis283
(Dimis283)
5
Very strange but it works.