12 public function __construct(
$identifier, $name = NULL, $label = NULL, $value = NULL, $inputType =
"checkbox", $type =
"checkbox") {
13 parent::__construct(
"ck-" .
$identifier,
"div",
"ui " . $type);
15 $field = new \Ajax\common\html\html5\HtmlInput(
$identifier, $inputType, $value);
16 $field->setProperty(
"name", $name);
24 if ($value ===
true) {
25 $this->
getField()->setProperty(
"checked",
"checked");
27 $this->
getField()->removeProperty(
"checked");
33 $this->
getField()->forceValue($value);
38 return $this->
addToPropertyCtrl(
"class", $checkboxType, CheckboxType::getConstants());
41 public function setLabel($label, $value =
null) {
43 if (\is_string($label)) {
45 $labelO->setContent($label);
46 $labelO->setProperty(
"for", $this->
getField()
49 $labelO->setProperty(
"data-value", $value);
51 $this->content[
"label"] = $labelO;
55 $this->content[
"field"] = $field;
64 if (\array_key_exists(
"label", $this->content))
65 return $this->content[
"label"];
74 return $this->content[
"field"];
82 unset($this->content[
"label"]);
83 $this->content[
"label"] = $label;
87 $this->
getField()->setProperty(
"disabled",
"disabled");
101 if (isset($action) || \is_numeric($action) ===
true) {
102 $js =
'$("#%identifier%").checkbox("attach events", "' . $selector .
'", "' . $action .
'");';
104 $js =
'$("#%identifier%").checkbox("attach events", "' . $selector .
'");';
106 $js = \str_replace(
"%identifier%", $this->identifier, $js);
118 if (\is_array($events)) {
119 foreach ($events as $action => $selector) {
131 $this->_params[
"onChecked"] = $jsCode;
136 $this->_params[
"onUnchecked"] = $jsCode;
141 $this->_params[
"onChange"] = $jsCode;
146 if (! isset($this->_bsComponent))
147 $this->_bsComponent = $js->
semantic()->checkbox(
"#" . $this->identifier, $this->_params);
148 return parent::run($js);
semantic(Semantic $semantic=NULL)
getter or setter of the Semantic-UI variable
Base class for Semantic double elements.
addToProperty($name, $value, $separator=" ")
addToPropertyCtrl($name, $value, $typeCtrl)
getLabel()
Returns the label or null.
run(JsUtils $js)
{{SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()}HtmlDoubleElement:...
attachEvent($selector, $action=NULL)
Attach $this to $selector and fire $action.
getField()
Return the field.
attachEvents($events=array())
Attach $this to an array of $action=>$selector.
swapLabel()
puts the label before or behind
setLabel($label, $value=null)
forceValue($value='true')
__construct($identifier, $name=NULL, $label=NULL, $value=NULL, $inputType="checkbox", $type="checkbox")