I want to call an action of a controller from another controller.
How can I do this?
Some years ago, there were compononents, but they are not available any more.
Best regards
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t call an other controller’s action method.
You have only two solutions.
Doing a redirect to the appropriate URL.
But of course if you have datas from a form, you lose them.
Render the action from an other controller.
You keep all your defined datas (params and everything).
But you need to do again all what the other controller would do.
One solution to avoid repeating code lines would be to have a library method defining every vars you need in your view and use this method in your two controllers.