10 defined(
'JPATH_PLATFORM') or die;
31 protected $type =
'Checkbox';
39 protected $checked =
false;
50 public function __get($name)
58 return parent::__get($name);
71 public function __set($name, $value)
76 $value = (string) $value;
77 $this->$name = ($value ==
'true' || $value == $name || $value ==
'1');
81 parent::__set($name, $value);
99 public function setup(SimpleXMLElement $element, $value, $group = null)
101 $return = parent::setup($element, $value, $group);
105 $checked = (string) $this->element[
'checked'];
106 $this->checked = ($checked ==
'true' || $checked ==
'checked' || $checked ==
'1');
108 empty($this->value) || $this->checked ? null : $this->checked =
true;
122 protected function getInput()
125 $class = !empty($this->
class) ?
' class="' . $this->
class . '"' : '';
126 $disabled = $this->disabled ? ' disabled' : '';
127 $value = !empty($this->default) ? $this->default : '1';
128 $required = $this->required ? ' required aria-required="true"' : '';
129 $autofocus = $this->autofocus ? ' autofocus' : '';
130 $checked = $this->checked || !empty($this->value) ? ' checked' : '';
133 $onclick = !empty($this->onclick) ? ' onclick="' . $this->onclick . '"' : '';
134 $onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
137 JHtml::_('jquery.framework');
138 JHtml::_('script', 'system/html5fallback.js', false, true);
140 return '<input type="checkbox" name="' . $this->name . '" id="' . $this->id . '" value="'
141 . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"' . $class . $checked . $disabled . $onclick . $onchange
142 . $required . $autofocus . ' />';