From 75cd8d2c39437c935f833632b00e3f7ff9c6442b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 22 Aug 2014 12:27:31 +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') {