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:
22
form.php
22
form.php
@@ -315,19 +315,29 @@ class formfield
|
|||||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||||
$res .= " disabled='disabled'";
|
$res .= " disabled='disabled'";
|
||||||
// Do not check by default !
|
// 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 (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'";
|
$res .= " checked='checked'";
|
||||||
elseif (count ($this->titles) === 1 && isset ($this->defaults) &&
|
elseif (isset ($this->defaults) &&
|
||||||
$this->defaults !== null && $this->defaults !== false &&
|
$this->defaults !== null &&
|
||||||
$this->defaults !== "unset" && $this->defaults !== "")
|
$this->defaults !== false &&
|
||||||
|
$this->defaults !== "unset" &&
|
||||||
|
$this->defaults !== "")
|
||||||
$res .= " checked='checked'";
|
$res .= " checked='checked'";
|
||||||
}
|
}
|
||||||
else
|
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'";
|
$res .= " checked='checked'";
|
||||||
elseif (isset ($this->defaults[$key]) &&
|
elseif (isset ($this->defaults[$key]) &&
|
||||||
$this->defaults[$key] !== null &&
|
$this->defaults[$key] !== null &&
|
||||||
|
|||||||
Reference in New Issue
Block a user