diff --git a/form.php b/form.php index b8b4a6a..081df3f 100644 --- a/form.php +++ b/form.php @@ -51,6 +51,62 @@ class form $this->formName = $formName; } + // The setters of the properties + // {{{ + /** Set the debug level + * @param integer $val The debug value + */ + public function debug ($val) + { + $this->debug = $val; + return $this; + } + + /** Set the csrf enable + * @param integer $val The csrf check + */ + public function csrf ($val) + { + $this->csrf = !! $val; + return $this; + } + + /** Set the csrf token name + * @param integer $val The csrf token name + */ + public function csrfField ($val) + { + $this->csrfField = $val; + return $this; + } + + /** Set the titlewidth + * @param integer $val The titlewidth + */ + public function titlewidth ($val) + { + $this->titlewidth = $val; + return $this; + } + + /** Set the fieldwidth + * @param integer $val The fieldwidth + */ + public function fieldwidth ($val) + { + $this->fieldwidth = $val; + return $this; + } + + /** Set the formClass + * @param integer $val The formClass + */ + public function formClass ($val) + { + $this->formClass = $val; + return $this; + } + /** Set logging class an method * @param callable $loggingCallable The callable function. This method will * receive two params : the LOG level (LOG_ERROR...) and the message @@ -61,6 +117,7 @@ class form $this->loggingCallable = $loggingCallable; $this->loggingBasemsg = $loggingBasemsg; } + // }}} /** The private method to log if the $this->loggingCallable is defined */ @@ -157,9 +214,10 @@ class form // Remove the field CSRF : can not be used outside the form unset ($values[$this->csrfField]); } - if (isset ($_SESSION["domframework"]["form"]["fields"])) + if (isset ($_SESSION["domframework"]["form"][$this->formName]["fields"])) { - foreach ($_SESSION["domframework"]["form"]["fields"] as $field) + foreach ($_SESSION["domframework"]["form"][$this->formName]["fields"] as + $field) { if ($field->type === "hidden" || ($field->readonly !== null && $field->readonly !== false)) @@ -194,7 +252,8 @@ class form throw new Exception ("Can't display a form without defined field", 500); } if (isset ($_SESSION)) - $_SESSION["domframework"]["form"]["fields"] = $this->fields; + $_SESSION["domframework"]["form"][$this->formName]["fields"] = + $this->fields; $this->method = strtolower ($method); $res = ""; $res = "