badman
(Omzy83)
1
Suppose I have protected/controllers/PostController/actionCreate()
How can I re-use this same action (and its view) in protected/modules/admin/controllers/PostController/actionCreate()
I do not want to redirect the user - I just don’t want to have to replicate the same code in both actions.
alex-w
(Pr0j3ct A1ex)
2
Create a CAction class?
class PostCreate extends CAction
{
public function run()
{
}
}
Then reference it in your controller.
public function actions()
{
return array(
'create' => 'path here to action class file'
);
}
Keith
(Kburton)
3
badman
(Omzy83)
4
Keith - using forward() also brings in the layout file, which I do not want.
alex-w - do I need to create separate class files for each action?
alex-w
(Pr0j3ct A1ex)
6
No, You can still have actions in the controller.
Creating an action class just allows you to use it from other controllers.