diff --git a/wire/modules/Inputfield/InputfieldCheckbox.module b/wire/modules/Inputfield/InputfieldCheckbox.module index c45cfc73..68fe036b 100644 --- a/wire/modules/Inputfield/InputfieldCheckbox.module +++ b/wire/modules/Inputfield/InputfieldCheckbox.module @@ -40,6 +40,7 @@ class InputfieldCheckbox extends Inputfield { * */ public function __construct() { + $this->set('checkedValue', self::checkedValueDefault); $this->checkedValueIsLabel = false; // cancel line above $this->set('uncheckedValue', self::uncheckedValueDefault); @@ -54,13 +55,23 @@ class InputfieldCheckbox extends Inputfield { $this->set('labelAttrs', array()); // Optional attributes for "; return $out; } - /* TBA: May move to be a separate 'toggle' Inputfield, keeping for reference - public function ___renderRadio() { - - $attrs = $this->getAttributes(); - - $attrs['value'] = $this->checkedValue; - $attrs['checked'] = $this->attr('value') == $this->checkedValue ? 'checked' : ''; - if(empty($attrs['checked'])) unset($attrs['checked']); - $label = $this->entityEncode($this->checkedValue); - $out = "\n "; - - $attrs['value'] = $this->uncheckedValue; - $attrs['checked'] = $this->attr('value') == $this->uncheckedValue ? 'checked' : ''; - if(empty($attrs['checked'])) unset($attrs['checked']); - $label = $this->entityEncode($this->uncheckedValue); - $out .= "\n "; - - return $out; - } - */ - /** * Render value only * @@ -240,7 +245,6 @@ class InputfieldCheckbox extends Inputfield { * */ public function isEmpty() { - // return $this->attr('value') != $this->checkedValue; return !$this->checked(); } @@ -255,6 +259,7 @@ class InputfieldCheckbox extends Inputfield { $value = $input[$this->name]; $checked = $this->isChecked(); + if(!empty($value)) { if(!$checked) $this->trackChange('value', $this->uncheckedValue, $this->checkedValue); parent::attr('checked', 'checked');