Fix unable to have checkboxes with an unselected value that evaluates to false.

This commit is contained in:
Ralf Becker 2014-08-22 12:27:31 +00:00
parent 8c43c2847d
commit 75cd8d2c39

View File

@ -61,16 +61,19 @@ class etemplate_widget_checkbox extends etemplate_widget
$type = $this->type ? $this->type : $this->attrs['type']; $type = $this->type ? $this->type : $this->attrs['type'];
$value_attr = $type == 'radio' ? 'set_value' : 'selected_value'; $value_attr = $type == 'radio' ? 'set_value' : 'selected_value';
// defaults for set and unset values // 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; if(array_key_exists($value_attr, $this->attrs))
$unselected_value = false; {
} // Expand any content stuff
else $selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']);
{ }
// Expand any content stuff if(array_key_exists('unselected_value',$this->attrs))
$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']); $unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']);
}
} }
if ($type == 'radio') if ($type == 'radio')
{ {