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
This commit is contained in:
2018-03-21 13:19:45 +00:00
parent 00908b1164
commit fdb90a0816

View File

@@ -343,7 +343,8 @@ class form
* @param array $values The values of the fields filled by the user * @param array $values The values of the fields filled by the user
* @param array $errors The errors detected by a verify * @param array $errors The errors detected by a verify
* @param object $route the route object * @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 : * Example :
$form = new \form (); $form = new \form ();
@@ -355,11 +356,13 @@ class form
$spaceuuid = $spaceObj->spaceCreateConceal ($values["spacename"]); $spaceuuid = $spaceObj->spaceCreateConceal ($values["spacename"]);
$route->redirect ("/admin/space/"); $route->redirect ("/admin/space/");
*/ */
public function redirectIfError ($values, $errors, $route, $url) public function redirectIfError ($values, $errors, $route, $url = "")
{ {
$this->saveValuesErrors ($values, $errors); $this->saveValuesErrors ($values, $errors);
if ($url === "")
$url = "/".$route->requestURL ();
if (count ($errors)) $route->redirect ($url); 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 /** Save the values and errors to be displayed in the next page if the session