From d68b6fec007e5330b304b0ca126dd50dc2321957 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 27 Dec 2020 12:14:45 +0100 Subject: [PATCH] Fix #465 add option for redirect code to implement post/redirect/get pattern --- form.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/form.php b/form.php index 29f073f8..21dbab0c 100644 --- a/form.php +++ b/form.php @@ -482,9 +482,10 @@ public function onFormProcessed(Event $event) break; case 'redirect': $this->grav['session']->setFlashObject('form', $form); - $url = ((string)$params); + $url = (string)(is_array($params) ? $params['route'] : $params); $vars = array( - 'form' => $form + 'form' => $form, + 'page' => $this->grav['page'] ); /** @var Twig $twig */ $twig = $this->grav['twig']; @@ -496,6 +497,10 @@ public function onFormProcessed(Event $event) } $event['redirect'] = $url; + if (isset($params['redirect_code'])) { + $event['redirect_code'] = $params['redirect_code']; + } + $event->stopPropagation(); break; case 'reset':