form : allow checkbox to be multiple (in an array) or simple (in text)
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2213 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
34
form.php
34
form.php
@@ -276,24 +276,32 @@ class formfield
|
||||
$this->titles = array ("");
|
||||
foreach ($this->titles as $key=>$val)
|
||||
{
|
||||
$res .= "<div class='checkbox'>";
|
||||
$res .= " <input type='hidden'";
|
||||
$res .= " <div class='checkbox'>\n";
|
||||
$res .= " <input type='hidden'";
|
||||
$res .= " name='$this->formName"."[";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."][$key]'";
|
||||
$res .= " value='unset'";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]";
|
||||
if (count ($this->titles) > 1)
|
||||
$res .= "[$key]";
|
||||
$res .= "' value='unset'";
|
||||
$res .= "/>";
|
||||
$res .= "<input type='checkbox'";
|
||||
$res .= " name='$this->formName"."[";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."][$key]'";
|
||||
$res .= " id='$this->formName"."_";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_$key'";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]";
|
||||
if (count ($this->titles) > 1)
|
||||
$res .= "[$key]";
|
||||
$res .= "' id='$this->formName"."_";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES);
|
||||
if (count ($this->titles) > 1)
|
||||
$res .= "_$key";
|
||||
$res .= "'";
|
||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||
$res .= " disabled='disabled'";
|
||||
if (isset ($this->values[$key]) &&
|
||||
$this->values[$key] !== "unset")
|
||||
if (count ($this->titles) === 1 && isset ($this->values) &&
|
||||
$this->values !== "unset")
|
||||
$res .= " checked='checked'";
|
||||
elseif (isset ($this->defaults[$key]) &&
|
||||
$this->defaults[$key] !== "")
|
||||
elseif (isset ($this->values[$key]) && $this->values[$key] !== "unset")
|
||||
$res .= " checked='checked'";
|
||||
elseif (isset ($this->defaults[$key]) && $this->defaults[$key] !== "")
|
||||
$res .= " checked='checked'";
|
||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||
$res .= " style='display:none'";
|
||||
@@ -304,14 +312,14 @@ class formfield
|
||||
}
|
||||
$res .= "/>";
|
||||
$res .= "$val\n";
|
||||
$res .= "</div>\n";
|
||||
$res .= " </div>\n";
|
||||
}
|
||||
|
||||
if (isset ($this->errors) || isset ($this->help))
|
||||
{
|
||||
$res .= " <span class='help-block' id='$this->formName"."_";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'>";
|
||||
if (isset ($this->help)) $res .= $this->help."<br/>\n";
|
||||
if (isset ($this->help)) $res .= $this->help."<br/>";
|
||||
if (isset ($this->errors)) $res .= $this->errors[1];
|
||||
$res .= "</span>\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user