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

This commit is contained in:
Nathan Gray 2014-08-18 17:33:43 +00:00
parent 5b91e871de
commit 1e5ea67595

View File

@ -61,17 +61,20 @@ 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; $selected_value = true;
$unselected_value = false; $unselected_value = false;
} if (array_key_exists($value_attr, $this->attrs) || array_key_exists('unselected_value',$this->attrs))
else {
if(array_key_exists($value_attr, $this->attrs))
{ {
// Expand any content stuff // Expand any content stuff
$selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); $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']); $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')
{ {
$options = etemplate_widget_menupopup::selOptions($form_name, true); $options = etemplate_widget_menupopup::selOptions($form_name, true);