From bc23495eec98b5eb32ac965259a23e5e5b3c7d4f Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 26 Apr 2016 13:01:11 +0000 Subject: [PATCH] form : add maxlength support git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2707 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- form.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/form.php b/form.php index c2273e2..acafb0d 100644 --- a/form.php +++ b/form.php @@ -60,6 +60,7 @@ class form page - [mandatory] : boolean to add a red star at end of label - [hidden] : hide the field (add a style='display:hidden' to the field) + - [maxlength] : the maximum length of the content of the field in chars - [rows] : Number of rows - [cols] : Number of columns - [placeholder] : The text to be displayed in the placeholder @@ -355,7 +356,8 @@ class formfield /** Return the checkbox defined */ public function fieldcheckbox () { - // No $this->multiple, $this->rows $this->cols $this->placeholder + // No $this->multiple, $this->rows $this->cols $this->placeholder, + // $this->maxlength $res = ""; $res .= "
name, ENT_QUOTES)."]'"; @@ -518,6 +520,8 @@ class formfield $res .= " style='display:none'"; if (isset ($this->cols)) $res .= " size='".$this->cols."'"; + if (isset ($this->maxlength)) + $res .= " maxlength='".$this->maxlength."'"; if (isset ($this->errors) || isset ($this->help)) { $res .= " aria-describedby='".$this->formName."_"; @@ -546,6 +550,7 @@ class formfield { $res = ""; // No $this->multiple, $this->rows $this->cols $this->placeholder + // $this->maxlength $res .= "
label, $this->multiple, $this->error, $this->rows, - // $this->cols $this->placeholder + // $this->cols $this->placeholder $this->maxlength $res .= "
\n"; $res .= "
\n"; @@ -791,6 +796,8 @@ class formfield if (!isset ($this->rows)) $this->rows = 4; $res .= " rows='".$this->rows."'"; + if (isset ($this->maxlength)) + $res .= " maxlength='".$this->maxlength."'"; if (isset ($this->errors) || isset ($this->help)) { $res .= " aria-describedby='".$this->formName."_"; @@ -859,6 +866,8 @@ class formfield $res .= " style='display:none'"; if (isset ($this->cols)) $res .= " size='".$this->cols."'"; + if (isset ($this->maxlength)) + $res .= " maxlength='".$this->maxlength."'"; if (isset ($this->errors) || isset ($this->help)) { $res .= " aria-describedby='".$this->formName."_";