Answer the question
In order to leave comments, you need to log in
How to render in Yii in external activity?
Good afternoon,
I decided to collect the common moments of 2 similar models into behavior, and the common actions of controllers into external actions. Faced the following problem:
Created an external action:
class ShowTreeAction extends CAction{
public $pk = 'id';
public $modelClass;
function run(){
if(empty($_GET[$this->pk]))
throw new CHttpException(404);
$this->render('item',array('model'=>CActiveRecord::model($this->modelClass)->findByPk($this->pk)));
}
}
function actions(){
return array(
'item'=>array(
'class'=>'ShowTreeAction',
'modelClass' => 'Service'
)
);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question