form : remove the prefix, which is not compatible with the definition of values. The developper must use it's own prefix method
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2169 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
57
form.php
57
form.php
@@ -54,8 +54,6 @@ 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)
|
||||||
- [prefix] : the prefix added to the name (in XXX/YYY/ZZZ form).
|
|
||||||
Will form an array to the result
|
|
||||||
- [rows] : Number of rows
|
- [rows] : Number of rows
|
||||||
- [cols] : Number of columns
|
- [cols] : Number of columns
|
||||||
|
|
||||||
@@ -211,9 +209,6 @@ class formfield
|
|||||||
public $mandatory;
|
public $mandatory;
|
||||||
/** The statut of error of the field */
|
/** The statut of error of the field */
|
||||||
public $error;
|
public $error;
|
||||||
/** the prefix added to the name (in XXX/YYY/ZZZ form). Will form an array to
|
|
||||||
the result */
|
|
||||||
public $prefix;
|
|
||||||
/** Number of rows */
|
/** Number of rows */
|
||||||
public $rows;
|
public $rows;
|
||||||
/** Number of columns */
|
/** Number of columns */
|
||||||
@@ -245,8 +240,6 @@ class formfield
|
|||||||
$res .= "'>\n";
|
$res .= "'>\n";
|
||||||
$res .= " <label class='col-sm-2 control-label' for='".
|
$res .= " <label class='col-sm-2 control-label' for='".
|
||||||
$this->formName."_";
|
$this->formName."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_0'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_0'";
|
||||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
@@ -264,19 +257,13 @@ class formfield
|
|||||||
{
|
{
|
||||||
$res .= " <input type='hidden'";
|
$res .= " <input type='hidden'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."][$key]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."][$key]'";
|
||||||
$res .= " value='unset'";
|
$res .= " value='unset'";
|
||||||
$res .= "/>";
|
$res .= "/>";
|
||||||
$res .= "<input type='checkbox'";
|
$res .= "<input type='checkbox'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."][$key]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."][$key]'";
|
||||||
$res .= " id='$this->formName"."_";
|
$res .= " id='$this->formName"."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_$key'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_$key'";
|
||||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||||
$res .= " disabled='disabled'";
|
$res .= " disabled='disabled'";
|
||||||
@@ -309,12 +296,8 @@ class formfield
|
|||||||
// $this->rows $this->cols
|
// $this->rows $this->cols
|
||||||
$res .= "<input type='hidden'";
|
$res .= "<input type='hidden'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
$res .= " id='$this->formName"."_";
|
$res .= " id='$this->formName"."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($values[$this->name]))
|
if (isset ($values[$this->name]))
|
||||||
$res .= " value='".htmlspecialchars ($values[$this->name])."'";
|
$res .= " value='".htmlspecialchars ($values[$this->name])."'";
|
||||||
@@ -335,8 +318,6 @@ class formfield
|
|||||||
$res .= "'>\n";
|
$res .= "'>\n";
|
||||||
$res .= " <label class='col-sm-2 control-label' for='".
|
$res .= " <label class='col-sm-2 control-label' for='".
|
||||||
$this->formName."_";
|
$this->formName."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
@@ -350,12 +331,8 @@ class formfield
|
|||||||
$res .= " <div class='col-sm-10'>\n";
|
$res .= " <div class='col-sm-10'>\n";
|
||||||
$res .= " <input type='password'";
|
$res .= " <input type='password'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
$res .= " id='$this->formName"."_";
|
$res .= " id='$this->formName"."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($values[$this->name]))
|
if (isset ($values[$this->name]))
|
||||||
$res .= " value='".htmlspecialchars ($values[$this->name],
|
$res .= " value='".htmlspecialchars ($values[$this->name],
|
||||||
@@ -388,8 +365,6 @@ class formfield
|
|||||||
$res .= "'>\n";
|
$res .= "'>\n";
|
||||||
$res .= " <label class='col-sm-2 control-label' for='".
|
$res .= " <label class='col-sm-2 control-label' for='".
|
||||||
$this->formName."_";
|
$this->formName."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_0'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_0'";
|
||||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
@@ -405,8 +380,6 @@ class formfield
|
|||||||
$this->defaults = array ($this->defaults);
|
$this->defaults = array ($this->defaults);
|
||||||
$res .= " <input type='hidden'";
|
$res .= " <input type='hidden'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
$res .= " value='unset'";
|
$res .= " value='unset'";
|
||||||
$res .= "/>\n";
|
$res .= "/>\n";
|
||||||
@@ -415,12 +388,8 @@ class formfield
|
|||||||
$res .= " <label class='radio'>";
|
$res .= " <label class='radio'>";
|
||||||
$res .= "<input type='radio'";
|
$res .= "<input type='radio'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
$res .= " id='$this->formName"."_";
|
$res .= " id='$this->formName"."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_$key'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_$key'";
|
||||||
$res .= " value='".htmlspecialchars ($val, ENT_QUOTES)."'";
|
$res .= " value='".htmlspecialchars ($val, ENT_QUOTES)."'";
|
||||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||||
@@ -458,8 +427,6 @@ class formfield
|
|||||||
$res .= "'>\n";
|
$res .= "'>\n";
|
||||||
$res .= " <label class='col-sm-2 control-label' for='".
|
$res .= " <label class='col-sm-2 control-label' for='".
|
||||||
$this->formName."_";
|
$this->formName."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
@@ -481,16 +448,12 @@ class formfield
|
|||||||
if (isset ($this->multiple) && $this->multiple !== FALSE)
|
if (isset ($this->multiple) && $this->multiple !== FALSE)
|
||||||
{
|
{
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."][".
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."][".
|
||||||
htmlspecialchars ($key, ENT_QUOTES)."]'";
|
htmlspecialchars ($key, ENT_QUOTES)."]'";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
}
|
}
|
||||||
$res .= " value='";
|
$res .= " value='";
|
||||||
@@ -501,15 +464,11 @@ class formfield
|
|||||||
|
|
||||||
$res .= " <select";
|
$res .= " <select";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]";
|
||||||
if (isset ($this->multiple) && $this->multiple !== FALSE)
|
if (isset ($this->multiple) && $this->multiple !== FALSE)
|
||||||
$res .= "[]";
|
$res .= "[]";
|
||||||
$res .= "'";
|
$res .= "'";
|
||||||
$res .= " id='$this->formName"."_";
|
$res .= " id='$this->formName"."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($this->multiple) && $this->multiple !== FALSE)
|
if (isset ($this->multiple) && $this->multiple !== FALSE)
|
||||||
$res .= " multiple='multiple'";
|
$res .= " multiple='multiple'";
|
||||||
@@ -563,12 +522,8 @@ class formfield
|
|||||||
$res .= " <div class='col-sm-12'>\n";
|
$res .= " <div class='col-sm-12'>\n";
|
||||||
$res .= " <input type='submit'";
|
$res .= " <input type='submit'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
$res .= " id='$this->formName"."_";
|
$res .= " id='$this->formName"."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||||
$res .= " disabled='disabled'";
|
$res .= " disabled='disabled'";
|
||||||
@@ -597,8 +552,6 @@ class formfield
|
|||||||
$res .= "'>\n";
|
$res .= "'>\n";
|
||||||
$res .= " <label class='col-sm-2 control-label' for='".
|
$res .= " <label class='col-sm-2 control-label' for='".
|
||||||
$this->formName."_";
|
$this->formName."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
@@ -612,12 +565,8 @@ class formfield
|
|||||||
$res .= " <div class='col-sm-10'>\n";
|
$res .= " <div class='col-sm-10'>\n";
|
||||||
$res .= " <textarea";
|
$res .= " <textarea";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
$res .= " id='$this->formName"."_";
|
$res .= " id='$this->formName"."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||||
$res .= " readonly='readonly'";
|
$res .= " readonly='readonly'";
|
||||||
@@ -655,8 +604,6 @@ class formfield
|
|||||||
$res .= "'>\n";
|
$res .= "'>\n";
|
||||||
$res .= " <label class='col-sm-2 control-label' for='".
|
$res .= " <label class='col-sm-2 control-label' for='".
|
||||||
$this->formName."_";
|
$this->formName."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
@@ -670,12 +617,8 @@ class formfield
|
|||||||
$res .= " <div class='col-sm-10'>\n";
|
$res .= " <div class='col-sm-10'>\n";
|
||||||
$res .= " <input type='text'";
|
$res .= " <input type='text'";
|
||||||
$res .= " name='$this->formName"."[";
|
$res .= " name='$this->formName"."[";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= implode ("][", explode ("/", $this->prefix))."][";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||||
$res .= " id='$this->formName"."_";
|
$res .= " id='$this->formName"."_";
|
||||||
if (isset ($this->prefix))
|
|
||||||
$res .= preg_replace ("#[/ ]#", "_", $this->prefix)."_";
|
|
||||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||||
if (isset ($values[$this->name]))
|
if (isset ($values[$this->name]))
|
||||||
$res .= " value='".htmlspecialchars ($values[$this->name],
|
$res .= " value='".htmlspecialchars ($values[$this->name],
|
||||||
|
|||||||
Reference in New Issue
Block a user