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 .= " ";
|
||||||
$res .= "</label>\n";
|
$res .= "</label>\n";
|
||||||
$res .= " <div class='col-sm-10'>\n";
|
$res .= " <div class='col-sm-10'>\n";
|
||||||
if (is_string ($this->defaults))
|
|
||||||
$this->defaults = array ($this->defaults);
|
|
||||||
if (count ($this->titles) === 0)
|
if (count ($this->titles) === 0)
|
||||||
$this->titles = array ("");
|
$this->titles = array ("");
|
||||||
foreach ($this->titles as $key=>$val)
|
foreach ($this->titles as $key=>$val)
|
||||||
@@ -316,13 +314,28 @@ class formfield
|
|||||||
$res .= "'";
|
$res .= "'";
|
||||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||||
$res .= " disabled='disabled'";
|
$res .= " disabled='disabled'";
|
||||||
if (count ($this->titles) === 1 && isset ($this->values) &&
|
// Do not check by default !
|
||||||
$this->values !== "unset")
|
// Check is enable if not null, false, 'unset' or ''
|
||||||
$res .= " checked='checked'";
|
if (count ($this->titles) === 1)
|
||||||
elseif (isset ($this->values[$key]) && $this->values[$key] !== "unset")
|
{
|
||||||
$res .= " checked='checked'";
|
if (isset ($this->values) && $this->values !== "unset")
|
||||||
elseif (isset ($this->defaults[$key]) && $this->defaults[$key] !== "")
|
$res .= " checked='checked'";
|
||||||
$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)
|
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||||
$res .= " style='display:none'";
|
$res .= " style='display:none'";
|
||||||
if (isset ($this->errors) || isset ($this->help))
|
if (isset ($this->errors) || isset ($this->help))
|
||||||
|
|||||||
Reference in New Issue
Block a user