chg: [CRUD] component - added redirect_controller parameter

- redirect to other controllers on demand, not just other actions
pull/7377/head
iglocska 2021-04-27 00:42:23 +02:00
parent d1286605b9
commit 10d75dfcd6
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 7 additions and 0 deletions

View File

@ -117,6 +117,13 @@ class CRUDComponent extends Component
}
$redirect = isset($params['redirect']) ? $params['redirect'] : ['action' => 'index'];
if (!empty($params['redirect_controller'])) {
if (is_array($redirect)) {
$redirect['controller'] = $params['redirect_controller'];
} else {
$redirect = '/' . $params['redirect_controller'] . '/' . $redirect;
}
}
// For AJAX requests doesn't make sense to redirect, redirect must be done on javascript side in `submitGenericFormInPlace`
if ($this->Controller->request->is('ajax')) {
$redirect = Router::url($redirect);