E
E
EVOSandru62015-01-19 09:55:50
Yii
EVOSandru6, 2015-01-19 09:55:50

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)));
    }
}

Added an action in the controller:
function actions(){
        return array(
            'item'=>array(
                'class'=>'ShowTreeAction',
                'modelClass' => 'Service'
            )
        );
    }

But when switching to the action item , the following error pops up:
No method or closure with the name "render" was found in the ShowTreeAction class and its behaviors.
How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2015-01-19
@AMar4enko

$this->controller->render(...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question