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:
9
form.php
9
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
|
||||
|
||||
Reference in New Issue
Block a user