form : add maxlength support
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2707 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
17
form.php
17
form.php
@@ -60,6 +60,7 @@ class form
|
|||||||
page
|
page
|
||||||
- [mandatory] : boolean to add a red star at end of label
|
- [mandatory] : boolean to add a red star at end of label
|
||||||
- [hidden] : hide the field (add a style='display:hidden' to the field)
|
- [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
|
- [rows] : Number of rows
|
||||||
- [cols] : Number of columns
|
- [cols] : Number of columns
|
||||||
- [placeholder] : The text to be displayed in the placeholder
|
- [placeholder] : The text to be displayed in the placeholder
|
||||||
@@ -355,7 +356,8 @@ class formfield
|
|||||||
/** Return the checkbox defined */
|
/** Return the checkbox defined */
|
||||||
public function fieldcheckbox ()
|
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 = "";
|
||||||
$res .= "<div class='form-group";
|
$res .= "<div class='form-group";
|
||||||
if (isset ($this->errors))
|
if (isset ($this->errors))
|
||||||
@@ -464,7 +466,7 @@ class formfield
|
|||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->label, $this->multiple, $this->readonly, $this->hidden,
|
// No $this->label, $this->multiple, $this->readonly, $this->hidden,
|
||||||
// $this->rows $this->cols $this->placeholder
|
// $this->rows $this->cols $this->placeholder $this->maxlength
|
||||||
$res .= "<input type='hidden'";
|
$res .= "<input type='hidden'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
@@ -518,6 +520,8 @@ class formfield
|
|||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
if (isset ($this->cols))
|
if (isset ($this->cols))
|
||||||
$res .= " size='".$this->cols."'";
|
$res .= " size='".$this->cols."'";
|
||||||
|
if (isset ($this->maxlength))
|
||||||
|
$res .= " maxlength='".$this->maxlength."'";
|
||||||
if (isset ($this->errors) || isset ($this->help))
|
if (isset ($this->errors) || isset ($this->help))
|
||||||
{
|
{
|
||||||
$res .= " aria-describedby='".$this->formName."_";
|
$res .= " aria-describedby='".$this->formName."_";
|
||||||
@@ -546,6 +550,7 @@ class formfield
|
|||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->multiple, $this->rows $this->cols $this->placeholder
|
// No $this->multiple, $this->rows $this->cols $this->placeholder
|
||||||
|
// $this->maxlength
|
||||||
$res .= "<div class='form-group";
|
$res .= "<div class='form-group";
|
||||||
if (isset ($this->errors))
|
if (isset ($this->errors))
|
||||||
$res .= " has-".$this->errors[0];
|
$res .= " has-".$this->errors[0];
|
||||||
@@ -618,7 +623,7 @@ class formfield
|
|||||||
/** Return the checkbox defined */
|
/** Return the checkbox defined */
|
||||||
public function fieldselect ()
|
public function fieldselect ()
|
||||||
{
|
{
|
||||||
// No $this->placeholder
|
// No $this->placeholder $this->maxlength
|
||||||
$res = "";
|
$res = "";
|
||||||
// $values->$this, $this->cols
|
// $values->$this, $this->cols
|
||||||
$res .= "<div class='form-group";
|
$res .= "<div class='form-group";
|
||||||
@@ -728,7 +733,7 @@ class formfield
|
|||||||
{
|
{
|
||||||
$res = "";
|
$res = "";
|
||||||
// No $this->label, $this->multiple, $this->error, $this->rows,
|
// No $this->label, $this->multiple, $this->error, $this->rows,
|
||||||
// $this->cols $this->placeholder
|
// $this->cols $this->placeholder $this->maxlength
|
||||||
$res .= "<div class='form-group'>\n";
|
$res .= "<div class='form-group'>\n";
|
||||||
$res .= " <div class='col-sm-".($this->titlewidth+$this->fieldwidth).
|
$res .= " <div class='col-sm-".($this->titlewidth+$this->fieldwidth).
|
||||||
"'>\n";
|
"'>\n";
|
||||||
@@ -791,6 +796,8 @@ class formfield
|
|||||||
if (!isset ($this->rows))
|
if (!isset ($this->rows))
|
||||||
$this->rows = 4;
|
$this->rows = 4;
|
||||||
$res .= " rows='".$this->rows."'";
|
$res .= " rows='".$this->rows."'";
|
||||||
|
if (isset ($this->maxlength))
|
||||||
|
$res .= " maxlength='".$this->maxlength."'";
|
||||||
if (isset ($this->errors) || isset ($this->help))
|
if (isset ($this->errors) || isset ($this->help))
|
||||||
{
|
{
|
||||||
$res .= " aria-describedby='".$this->formName."_";
|
$res .= " aria-describedby='".$this->formName."_";
|
||||||
@@ -859,6 +866,8 @@ class formfield
|
|||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
if (isset ($this->cols))
|
if (isset ($this->cols))
|
||||||
$res .= " size='".$this->cols."'";
|
$res .= " size='".$this->cols."'";
|
||||||
|
if (isset ($this->maxlength))
|
||||||
|
$res .= " maxlength='".$this->maxlength."'";
|
||||||
if (isset ($this->errors) || isset ($this->help))
|
if (isset ($this->errors) || isset ($this->help))
|
||||||
{
|
{
|
||||||
$res .= " aria-describedby='".$this->formName."_";
|
$res .= " aria-describedby='".$this->formName."_";
|
||||||
|
|||||||
Reference in New Issue
Block a user