How to call controller method inside CDetailView?

Hi,

I tried calling a controller method inside a CDetailView column, but it gave me a CException:




$this->widget('zii.widgets.CDetailView', array(

	'data'=>$model,

	'attributes'=>array(

		'id',

		'title',

		'category',

		'description',

		'keyword',

		'$this->convertTime(create_time)',

		'update_time',

		'author_id'

What’s wrong with it?

$this in this case refers to the widget.

use Yii::app()->controller instead

I tried what you suggested, but received an error Property "Flowbook.Yii" is not defined.




'Yii::app()->FlowbookController::convertTime(create_time)',



not Yii::app()->FlowbookController::convertTime

but Yii::app()->controller->convertTime

you should also use $data->create_time, not create_time, so finally write:




'Yii::app()->controller->convertTime($data->create_time)'



Thanks! It’s working!