call action of another controller
yii
Solution
It's bad practice to use controller actions this way. Better place your code in model's method. But if you still want to do this, here is one way:
'value' => function() {
list($controller) = Yii::app()->createController('controllerId');
return $controller->actionTest();
}
Here is another:
'value' => function() {
$controller = new TestController('test');
return $controller->actionTest();
}
Problem
i have a grid view and i would like to get value of column from another action controller. at now i have this in controller 1 ``` array( 'name'=>'title', 'value'=>array($this,'Action2'), ), ``` and i get this error: ``` controller1 and its behaviors do not have a method or closure named "Action2". ``` if i replace $this with "controller2" ``` array( 'name'=>'title', 'value'=>array('controller2','Action2'), ), ``` i get this error ``` call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'controller2::action2' was given ``` maybe this is bad practice but is this feasible?