From 1e5ea675959b19a93062fd8a82d9d8b755ce968e Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 18 Aug 2014 17:33:43 +0000 Subject: [PATCH] Fix unable to have checkboxes with an unselected value that evaluates to false. --- .../class.etemplate_widget_checkbox.inc.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_checkbox.inc.php b/etemplate/inc/class.etemplate_widget_checkbox.inc.php index 2f3216f6a3..919130a9e2 100644 --- a/etemplate/inc/class.etemplate_widget_checkbox.inc.php +++ b/etemplate/inc/class.etemplate_widget_checkbox.inc.php @@ -61,16 +61,19 @@ class etemplate_widget_checkbox extends etemplate_widget $type = $this->type ? $this->type : $this->attrs['type']; $value_attr = $type == 'radio' ? 'set_value' : 'selected_value'; // defaults for set and unset values - if (!$this->attrs[$value_attr] && !$this->attrs['unselected_value']) + $selected_value = true; + $unselected_value = false; + if (array_key_exists($value_attr, $this->attrs) || array_key_exists('unselected_value',$this->attrs)) { - $selected_value = true; - $unselected_value = false; - } - else - { - // Expand any content stuff - $selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); - $unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); + if(array_key_exists($value_attr, $this->attrs)) + { + // Expand any content stuff + $selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); + } + if(array_key_exists('unselected_value',$this->attrs)) + { + $unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); + } } if ($type == 'radio') {