简体   繁体   中英

Redirect with array parameter Cakephp

I'm working on a Cakephp project, I have one controller that made some algorithms and save information to an array. I need to call another method on that same controller and send the array as a parameter. I need to do this using redirect, just like this:

return $this->redirect(['controller' => 'Identities', 'action' => 'myMethod', $array]);

If I don't use redirect, I will not have the view of the myMethod, and I need it, but I need to have the array information on that view, something like doing $this->set to pass the array to a view.

However, I get this error:

rawurlencode() expects parameter 1 to be string, array given

How can I send the array as a parameter?

You can use query string like this.

return $this->redirect(['controller' => 'Identities', 'action' => 'myMethod', '?' => ['param1' => 'val1', 'param2' => 'val2']]);

You can provide routed elements or query string parameters.

Source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM