diff --git a/form.php b/form.php index a694f61..2178bc0 100644 --- a/form.php +++ b/form.php @@ -291,8 +291,6 @@ class formfield $res .= " "; $res .= "\n"; $res .= "
\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))