On my index page I have a CGridView in which one of the columns I format using my own function (to generate image in it along with corresponding hint):
<?php
$this->widget('zii.widgets.grid.CGridView', array
(
...
'columns'=>array
(
...
array
(
'name'=>'STAT',
'type'=>'raw',
'value'=>'generateImgTag($data->STAT)',
),
),
));
function generateImgTag($status)
{
$hint = 'Status zlecenia: '
$img = '<img title="'.$hint.'" src="'.Yii::app()->request->baseUrl.'/gfx/status_'.strtolower($status).'.gif" width="25" height="15" alt="'.$hint.'" border="0">';
return $img;
}
?>Clicking on button in CButtonColumn of this CGridView leads user to a detail page, where I use CDetailView instead. It uses the same model, therefore, its attributes are the same as CGridView columns. But when I'm trying to format the same (STAT) column using the same function:
<?php
$this->widget('zii.widgets.CDetailView', array
(
'data'=>$model,
'attributes'=>array
(
'BCODE',
'DATR',
'DATZ',
array
(
'name'=>'STAT',
'type'=>'raw',
'value'=>'generateImgTag($data->STAT)',
),
),
));
?>I'm getting function name just written (treated as a string?). Can I use the same function to format CDetailView row or the only option is to use CDetailView's itemTemplate and code image tag inside it?

Help
















