Skip to content

Commit 39c2e11

Browse files
Dmytro Nozdrinsusannemoog
authored andcommitted
[BUGFIX] Make unique id for same checkboxes in different sections
Checkboxes that are placed in sections in BE forms have the same HTML identifiers. As a result it is not possible to check one checkbox in one section without affecting the same checkboxes in other sections. The fix makes identifiers unique. Resolves: #87429 Releases: master, 9.5 Change-Id: Ia5cd88aecb2af12a83f40d39a8b450f5cde09060 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62977 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Susanne Moog <look@susi.dev> Reviewed-by: Susanne Moog <look@susi.dev>
1 parent 3e8aa38 commit 39c2e11

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

typo3/sysext/backend/Classes/Form/Element/CheckboxElement.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use TYPO3\CMS\Core\Imaging\Icon;
2020
use TYPO3\CMS\Core\Imaging\IconRegistry;
2121
use TYPO3\CMS\Core\Utility\GeneralUtility;
22+
use TYPO3\CMS\Core\Utility\StringUtility;
2223

2324
/**
2425
* Generation of TCEform elements of the type "check"
@@ -181,7 +182,8 @@ protected function renderSingleCheckboxElement($label, $itemCounter, $formElemen
181182
$numberOfItems,
182183
implode('', $additionalInformation['fieldChangeFunc'])
183184
);
184-
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter;
185+
$uniqueId = StringUtility::getUniqueId('_');
186+
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter . $uniqueId;
185187

186188
$iconIdentifierChecked = !empty($config['items'][$itemCounter]['iconIdentifierChecked']) ? $config['items'][$itemCounter]['iconIdentifierChecked'] : 'actions-check';
187189
if (!$this->iconRegistry->isRegistered($iconIdentifierChecked)) {

typo3/sysext/backend/Classes/Form/Element/CheckboxLabeledToggleElement.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use TYPO3\CMS\Backend\Form\NodeFactory;
1919
use TYPO3\CMS\Core\Imaging\IconRegistry;
2020
use TYPO3\CMS\Core\Utility\GeneralUtility;
21+
use TYPO3\CMS\Core\Utility\StringUtility;
2122

2223
/**
2324
* Generation of TCEform elements of the type "check"
@@ -180,7 +181,8 @@ protected function renderSingleCheckboxElement($label, $itemCounter, $formElemen
180181
$numberOfItems,
181182
implode('', $additionalInformation['fieldChangeFunc'])
182183
);
183-
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter;
184+
$uniqueId = StringUtility::getUniqueId('_');
185+
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter . $uniqueId;
184186
return '
185187
<div class="checkbox checkbox-type-labeled-toggle' . ($invert ? ' checkbox-invert' : '') . ($inline ? ' checkbox-inline' : '') . (!$disabled ? '' : ' disabled') . '">
186188
<input type="checkbox"

typo3/sysext/backend/Classes/Form/Element/CheckboxToggleElement.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use TYPO3\CMS\Backend\Form\NodeFactory;
1919
use TYPO3\CMS\Core\Imaging\IconRegistry;
2020
use TYPO3\CMS\Core\Utility\GeneralUtility;
21+
use TYPO3\CMS\Core\Utility\StringUtility;
2122

2223
/**
2324
* Generation of TCEform elements of the type "check"
@@ -180,7 +181,8 @@ protected function renderSingleCheckboxElement($label, $itemCounter, $formElemen
180181
$numberOfItems,
181182
implode('', $additionalInformation['fieldChangeFunc'])
182183
);
183-
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter;
184+
$uniqueId = StringUtility::getUniqueId('_');
185+
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter . $uniqueId;
184186
return '
185187
<div class="checkbox checkbox-type-toggle' . ($invert ? ' checkbox-invert' : '') . ($inline ? ' checkbox-inline' : '') . (!$disabled ? '' : ' disabled') . '">
186188
<input type="checkbox"

0 commit comments

Comments
 (0)