From fdb90a08168fbdda34507c39c2e67352339a7888 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 21 Mar 2018 13:19:45 +0000 Subject: [PATCH] form : redirectIfError if the $url is not provided, redirect to the same page, but in method get git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4175 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- form.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/form.php b/form.php index 132452b..b8b4a6a 100644 --- a/form.php +++ b/form.php @@ -343,7 +343,8 @@ class form * @param array $values The values of the fields filled by the user * @param array $errors The errors detected by a verify * @param object $route the route object - * @param string $url The URL to redirect + * @param string|null $url The URL to redirect. If not provided, use the + * $route->requestURL () method to found the calling page * * Example : $form = new \form (); @@ -355,11 +356,13 @@ class form $spaceuuid = $spaceObj->spaceCreateConceal ($values["spacename"]); $route->redirect ("/admin/space/"); */ - public function redirectIfError ($values, $errors, $route, $url) + public function redirectIfError ($values, $errors, $route, $url = "") { $this->saveValuesErrors ($values, $errors); + if ($url === "") + $url = "/".$route->requestURL (); if (count ($errors)) $route->redirect ($url); - $form->saveValuesErrorsReset (); + $this->saveValuesErrorsReset (); } /** Save the values and errors to be displayed in the next page if the session