From 39980d8346d1e5a231ff81ca66e4d0c219706e3c Mon Sep 17 00:00:00 2001 From: Flynsarmy Date: Sun, 22 Mar 2020 16:32:27 +1000 Subject: [PATCH] Add formGetRedirectUrl method. (#4954) Fixes #4946. Documented in https://github.com/octobercms/docs/pull/432 --- modules/backend/behaviors/FormController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/backend/behaviors/FormController.php b/modules/backend/behaviors/FormController.php index 175571f54..b918a89c3 100644 --- a/modules/backend/behaviors/FormController.php +++ b/modules/backend/behaviors/FormController.php @@ -474,7 +474,7 @@ class FormController extends ControllerBehavior } if (post('redirect', true)) { - $redirectUrl = $this->getRedirectUrl($context); + $redirectUrl = $this->controller->formGetRedirectUrl($context, $model); } if ($model && $redirectUrl) { @@ -493,13 +493,15 @@ class FormController extends ControllerBehavior } /** - * Internal method that returns a redirect URL from the config based on - * supplied context. Otherwise the default redirect is used. + * Returns a redirect URL from the config based on supplied context. + * Otherwise the default redirect is used. Relative URLs are treated as + * backend URLs. * * @param string $context Redirect context, eg: create, update, delete. + * @param Model $model The active model. * @return string */ - protected function getRedirectUrl($context = null) + public function formGetRedirectUrl($context = null, $model = null) { $redirectContext = explode('-', $context, 2)[0]; $redirectSource = ends_with($context, '-close') ? 'redirectClose' : 'redirect';