form : allow the checkboxes to be unique or multiple. Manage correctely the defaults/values
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2217 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
31
form.php
31
form.php
@@ -291,8 +291,6 @@ class formfield
|
||||
$res .= " ";
|
||||
$res .= "</label>\n";
|
||||
$res .= " <div class='col-sm-10'>\n";
|
||||
if (is_string ($this->defaults))
|
||||
$this->defaults = array ($this->defaults);
|
||||
if (count ($this->titles) === 0)
|
||||
$this->titles = array ("");
|
||||
foreach ($this->titles as $key=>$val)
|
||||
@@ -316,13 +314,28 @@ class formfield
|
||||
$res .= "'";
|
||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||
$res .= " disabled='disabled'";
|
||||
if (count ($this->titles) === 1 && isset ($this->values) &&
|
||||
$this->values !== "unset")
|
||||
$res .= " checked='checked'";
|
||||
elseif (isset ($this->values[$key]) && $this->values[$key] !== "unset")
|
||||
$res .= " checked='checked'";
|
||||
elseif (isset ($this->defaults[$key]) && $this->defaults[$key] !== "")
|
||||
$res .= " checked='checked'";
|
||||
// Do not check by default !
|
||||
// Check is enable if not null, false, 'unset' or ''
|
||||
if (count ($this->titles) === 1)
|
||||
{
|
||||
if (isset ($this->values) && $this->values !== "unset")
|
||||
$res .= " checked='checked'";
|
||||
elseif (count ($this->titles) === 1 && isset ($this->defaults) &&
|
||||
$this->defaults !== null && $this->defaults !== false &&
|
||||
$this->defaults !== "unset" && $this->defaults !== "")
|
||||
$res .= " checked='checked'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset ($this->values[$key]) && $this->values[$key] !== "unset")
|
||||
$res .= " checked='checked'";
|
||||
elseif (isset ($this->defaults[$key]) &&
|
||||
$this->defaults[$key] !== null &&
|
||||
$this->defaults[$key] !== false &&
|
||||
$this->defaults[$key] !== "unset" &&
|
||||
$this->defaults[$key] !== "")
|
||||
$res .= " checked='checked'";
|
||||
}
|
||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||
$res .= " style='display:none'";
|
||||
if (isset ($this->errors) || isset ($this->help))
|
||||
|
||||
Reference in New Issue
Block a user