Calling a controller inside a controller in cakePHP 3.5:
return $this->redirect([‘controller’ => ‘reports’, ‘action’ => ‘show/’ . $report . ‘?filter=’ . urlencode($filter)]);
The variable $report is converted from ‘Konto_abgelaufen’ to ‘konto-abgelaufen’ inside the method show in controller ‘Reports’.
Can I avoid that? I need the content of $report in excat spelling.
As this is just a param, you can convert back the value inside the view-function using Inflector.
If this is a general issue for you: as far as I know you can change the Inflector that the Router is using in general to avoid this behavior (but this might cause other problems).
Btw.: You don’t have to use ‘?filter=’ to build your args manually, but can simply use
return $this->redirect([‘controller’ => ‘reports’, ‘action’ => ‘show’, $report, ‘?’ => [‘filter’ => $filter]]);
Thanks for that hints!
I tried to re-convert the string ‘konten-abgelaufen’ on https://inflector.cakephp.org/, but there seems to be no way back to ‘Konten_abgelaufen’ from ‘konten-abgelaufen’ using Inflector.
The “underscore” variant seems to (nearly) do what you need (except of the first character).
However - have you tried if the redirect-variant that I have posted before produces the same behavior? (Please note, the ‘,’ between ‘show’ and $report)
the redirect variant works, thank you!