Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Checkbox.php
Go to the documentation of this file.
1 <?php
7 
9 
16 {
23  public function __construct(
24  Factory $factoryElement,
25  CollectionFactory $factoryCollection,
26  Escaper $escaper,
27  $data = []
28  ) {
29  parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
30  $this->setType('checkbox');
31  $this->setExtType('checkbox');
32  }
33 
37  public function getHtmlAttributes()
38  {
39  return [
40  'type',
41  'title',
42  'class',
43  'style',
44  'checked',
45  'onclick',
46  'onchange',
47  'disabled',
48  'tabindex',
49  'data-form-part',
50  'data-role',
51  'data-action'
52  ];
53  }
54 
59  public function getElementHtml()
60  {
61  if ($checked = $this->getChecked()) {
62  $this->setData('checked', true);
63  } else {
64  $this->unsetData('checked');
65  }
66  return parent::getElementHtml();
67  }
68 
75  public function setIsChecked($value = false)
76  {
77  $this->setData('checked', $value);
78  return $this;
79  }
80 
87  public function getIsChecked()
88  {
89  return $this->getData('checked');
90  }
91 }
getData($key='', $index=null)
Definition: DataObject.php:119
$value
Definition: gender.phtml:16
__construct(Factory $factoryElement, CollectionFactory $factoryCollection, Escaper $escaper, $data=[])
Definition: Checkbox.php:23
setData($key, $value=null)
Definition: DataObject.php:72
$checked
Definition: billing.phtml:77