form : checkboxes : better management of defaults/values

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2218 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-08-07 08:24:41 +00:00
parent 20d58f427d
commit 83175e10b1

View File

@@ -315,19 +315,29 @@ class formfield
if (isset ($this->readonly) && $this->readonly !== FALSE)
$res .= " disabled='disabled'";
// Do not check by default !
// Check is enable if not null, false, 'unset' or ''
// Check is enable if not null and not false and not "unset" and not ""
if (count ($this->titles) === 1)
{
if (isset ($this->values) && $this->values !== "unset")
if (isset ($this->values) &&
$this->values !== null &&
$this->values !== false &&
$this->values !== "unset" &&
$this->values !== "")
$res .= " checked='checked'";
elseif (count ($this->titles) === 1 && isset ($this->defaults) &&
$this->defaults !== null && $this->defaults !== false &&
$this->defaults !== "unset" && $this->defaults !== "")
elseif (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")
if (isset ($this->values[$key]) &&
$this->values[$key] !== null &&
$this->values[$key] !== false &&
$this->values[$key] !== "unset" &&
$this->values[$key] !== "")
$res .= " checked='checked'";
elseif (isset ($this->defaults[$key]) &&
$this->defaults[$key] !== null &&