hi, all. i want to ask :
i have a table name tbl_packet with 1 field in it name status. in status i save a value with null,0,or 1.
and i want to show the status with word not number.
so i have a function like this:
public function getStatusPacket($id)
{
if($id == null )
$status = 'New';
else if($id == 0)
$status = 'Not Approved';
else if($id == 1)
$status = 'Approved';
return $status;
}
and i have a code like this in protected/view/packet/admin.php like this :
<?php
$session = new ChttpSession;
$session->open();
$columns[]=array(
'name' =>'name',
'type'=>'raw',
'value'=>'CHtml::link($data->packet_name,array("packet/view","id"=>$data->id))',
);
$columns[]=array(
'name'=>'packet_name',
'value'=>'$data->packet_name',
);
$columns[]=array(
'name'=>'packet_price',
'value'=>'$data->packet_price',
);
$columns[]=array(
'name'=>'packet_unit',
'value'=>'$data->packet_unit',
);
$columns[]=array(
'name'=>'status',
[u]'value'=>'Controller::getStatusPacket($data->status)'[/u], //get the word from it function in Controller.php
);
if($session['id'] != "")
{
if(Yii::app()->user->isAdmin())
{
$columns[]=array(
'header'=>'Action',
'class'=>'CButtonColumn',
);
}
else
{
$columns[]=array(
'header'=>'Action',
'class'=>'CButtonColumn',
'template'=>'{view}',
'buttons'=>array(
'view'=>array(
'label'=>'view',
'url'=>'Yii::app()->createUrl("Packet/view",array("id"=>$data->id))',
),
),
);
}
}
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'packet-grid',
'dataProvider'=>$model->search(),
'columns'=>$columns,
)); ?>
if i put the getStatusPacket function in controller, and in the admin.php i use Controller::getStatusPacket , its not working, it show error like this
1872
if i run it in another computer it works,can someone help me?