diff --git a/form.php b/form.php index 3c48458..a694f61 100644 --- a/form.php +++ b/form.php @@ -126,6 +126,17 @@ class form die ("FORM/VERIFY : UNUSED and deprecated\n"); } + /** Save the values and errors to be displayed in the next page if the session + is available */ + public function saveValuesErrors ($values, $errors) + { + if (isset ($_SESSION)) + { + $_SESSION["domframework"]["form"]["values"] = $values; + $_SESSION["domframework"]["form"]["errors"] = $errors; + } + } + /** Return the fields in HTML code. If $values is provided, use it in place of default values. In case of select boxes, $values are the selected elements @@ -147,6 +158,13 @@ class form $res .= " id='$this->formName'"; $res .= " class='form-horizontal'>\n"; $group = ""; + if (isset ($_SESSION["domframework"]["form"]["values"])) + { + $values = $_SESSION["domframework"]["form"]["values"]; + $errors = $_SESSION["domframework"]["form"]["errors"]; + unset ($_SESSION["domframework"]["form"]["values"]); + unset ($_SESSION["domframework"]["form"]["errors"]); + } foreach ($this->fields as $field) { $field->formName = $this->formName;