72 parent::initializeArguments();
73 $this->registerTagAttribute(
76 'Specifies that the input element should be disabled when the page loads'
78 $this->registerArgument(
81 'CSS class to set if there are errors for this ViewHelper',
85 $this->overrideArgument(
'value',
'string',
'Value of input tag. Required for checkboxes',
true);
86 $this->registerUniversalTagAttributes();
87 $this->registerArgument(
'checked',
'bool',
'Specifies that the input element should be preselected');
88 $this->registerArgument(
'multiple',
'bool',
'Specifies whether this checkbox belongs to a multivalue (is part of a checkbox group)',
false,
false);
99 $checked = $this->arguments[
'checked'];
100 $multiple = $this->arguments[
'multiple'];
102 $this->tag->addAttribute(
'type',
'checkbox');
106 $propertyValue =
null;
110 if ($checked ===
null && $propertyValue ===
null) {
114 if ($propertyValue instanceof \Traversable) {
115 $propertyValue = iterator_to_array($propertyValue);
117 if (is_array($propertyValue)) {
118 $propertyValue = array_map([$this,
'convertToPlainValue'], $propertyValue);
119 if ($checked ===
null) {
120 $checked = in_array($valueAttribute, $propertyValue);
122 $nameAttribute .=
'[]';
123 } elseif ($multiple ===
true) {
124 $nameAttribute .=
'[]';
125 } elseif ($propertyValue !==
null) {
126 $checked = (boolean)$propertyValue === (
boolean)$valueAttribute;
130 $this->tag->addAttribute(
'name', $nameAttribute);
131 $this->tag->addAttribute(
'value', $valueAttribute);
132 if ($checked ===
true) {
133 $this->tag->addAttribute(
'checked',
'checked');
138 return $hiddenField . $this->tag->render();