From 83175e10b15b1bbac380af369ac0c99520f041a6 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 7 Aug 2015 08:24:41 +0000 Subject: [PATCH] form : checkboxes : better management of defaults/values git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2218 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- form.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/form.php b/form.php index 2178bc0..653d407 100644 --- a/form.php +++ b/form.php @@ -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 &&