In a controller, what is the most appropriate way to call the action of another controller and also pass an array as parameter?
I know that you can use requestAction to call actions within other controllers. But is it possible to pass arrays as parameters using request action?
And no, I do not want to put the action in the App Controller. So that is not a solution for me.
The only other way I know is to load the other controller as explained in:
http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Configuration.html#importing-controllers-models-components-behaviors-views-and-helpers
But is there an easier way to just call the other controllers action while passing an array as parameter?
I am new to cakePHP so any suggestion is appreciated. Thanks.
Would it be appropriate for you to move the logic from the second controller into its model, then do something like this in your first controller’s action?
Then, in the view for the first controller’s action, you can use that data.
I always try to keep controller methods to actions you can hit through the browser, put as much logic in my models, call foreign model methods from controllers actions that need data from models that aren’t the model for that controller, then use that data in my views, and if it’s data that is viewed frequently, I create an element for it.