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