2 namespace TYPO3\CMS\Backend\Form\Element;
33 if ($this->data[
'parameterArray'][
'fieldConf'][
'config'][
'readOnly']) {
37 $items = $this->data[
'parameterArray'][
'fieldConf'][
'config'][
'items'];
39 $numberOfItems = count($items);
40 if ($numberOfItems === 0) {
41 $items[] = array(
'',
'');
44 $formElementValue = (int)$this->data[
'parameterArray'][
'itemFormElValue'];
45 $cols = (int)$this->data[
'parameterArray'][
'fieldConf'][
'config'][
'cols'];
47 $colWidth = (int)floor(12 / $cols);
48 $colClass =
"col-md-12";
51 $colClass =
"col-sm-6";
53 2 =>
'visible-sm-block visible-md-block visible-lg-block',
55 }
elseif ($colWidth === 4) {
56 $colClass =
"col-sm-4";
58 3 =>
'visible-sm-block visible-md-block visible-lg-block',
60 }
elseif ($colWidth === 3) {
61 $colClass =
"col-sm-6 col-md-3";
63 2 =>
'visible-sm-block',
64 4 =>
'visible-md-block visible-lg-block',
66 }
elseif ($colWidth <= 2) {
67 $colClass =
"checkbox-column col-sm-6 col-md-3 col-lg-2";
69 2 =>
'visible-sm-block',
70 4 =>
'visible-md-block',
71 6 =>
'visible-lg-block'
74 $html .=
'<div class="checkbox-row row">';
77 foreach ($items as $itemKey => $itemDefinition) {
78 $label = $itemDefinition[0];
80 '<div class="checkbox-column ' . $colClass .
'">'
81 . $this->
renderSingleCheckboxElement($label, $itemKey, $formElementValue, $numberOfItems, $this->data[
'parameterArray'], $disabled) .
83 $counter = $counter + 1;
84 if ($counter < $numberOfItems && !empty($colClear)) {
85 foreach ($colClear as $rowBreakAfter => $clearClass) {
86 if ($counter % $rowBreakAfter === 0) {
87 $html .=
'<div class="clearfix ' . $clearClass .
'"></div>';
95 foreach ($items as $itemKey => $itemDefinition) {
96 $label = $itemDefinition[0];
97 $html .= $this->
renderSingleCheckboxElement($label, $counter, $formElementValue, $numberOfItems, $this->data[
'parameterArray'], $disabled);
98 $counter = $counter + 1;
102 $html .=
'<input type="hidden" name="' . $this->data[
'parameterArray'][
'itemFormElName'] .
'" value="' . htmlspecialchars($formElementValue) .
'" />';
105 $resultArray[
'html'] = $html;
122 $config = $additionalInformation[
'fieldConf'][
'config'];
123 $inline = !empty($config[
'cols']) && $config[
'cols'] ===
"inline";
125 $additionalInformation[
'itemFormElName'],
129 implode(
'', $additionalInformation[
'fieldChangeFunc'])
131 $checkboxId = $additionalInformation[
'itemFormElID'] .
'_' . $itemCounter;
133 <div class="checkbox' . ($inline ?
' checkbox-inline' :
'') . (!$disabled ?
'' :
' disabled') .
'">
135 <input type="checkbox"
137 data-formengine-input-name="' . htmlspecialchars($additionalInformation[
'itemFormElName']) .
'"
138 ' . $checkboxParameters .
'
139 ' . $additionalInformation[
'onFocus'] .
'
140 ' . (!$disabled ?:
' disabled="disabled"') .
'
141 id="' . $checkboxId .
'" />
142 ' . ($label ? htmlspecialchars($label) :
' ') .
'
157 protected function checkBoxParams($itemName, $formElementValue, $checkbox, $checkboxesCount, $additionalJavaScript =
'')
159 $elementName =
'document.editform[' . Generalutility::quoteJSvalue($itemName) .
']';
160 $checkboxPow = pow(2, $checkbox);
161 $onClick = $elementName .
'.value=this.checked?(' . $elementName .
'.value|' . $checkboxPow .
'):('
162 . $elementName .
'.value&' . (pow(2, $checkboxesCount) - 1 - $checkboxPow) .
');' . $additionalJavaScript;
163 return ' onclick="' . htmlspecialchars($onClick) .
'"' . ($formElementValue & $checkboxPow ?
' checked="checked"' :
'');