Skip to content

Commit

Permalink
[BUGFIX] Make unique id for same checkboxes in different sections
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dnozdrin authored and susannemoog committed Jan 24, 2020
1 parent 3e8aa38 commit 39c2e11
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Expand Up @@ -19,6 +19,7 @@
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;

/**
* Generation of TCEform elements of the type "check"
Expand Down Expand Up @@ -181,7 +182,8 @@ protected function renderSingleCheckboxElement($label, $itemCounter, $formElemen
$numberOfItems,
implode('', $additionalInformation['fieldChangeFunc'])
);
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter;
$uniqueId = StringUtility::getUniqueId('_');
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter . $uniqueId;

$iconIdentifierChecked = !empty($config['items'][$itemCounter]['iconIdentifierChecked']) ? $config['items'][$itemCounter]['iconIdentifierChecked'] : 'actions-check';
if (!$this->iconRegistry->isRegistered($iconIdentifierChecked)) {
Expand Down
Expand Up @@ -18,6 +18,7 @@
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;

/**
* Generation of TCEform elements of the type "check"
Expand Down Expand Up @@ -180,7 +181,8 @@ protected function renderSingleCheckboxElement($label, $itemCounter, $formElemen
$numberOfItems,
implode('', $additionalInformation['fieldChangeFunc'])
);
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter;
$uniqueId = StringUtility::getUniqueId('_');
$checkboxId = $additionalInformation['itemFormElID'] . '_' . $itemCounter . $uniqueId;
return '
<div class="checkbox checkbox-type-labeled-toggle' . ($invert ? ' checkbox-invert' : '') . ($inline ? ' checkbox-inline' : '') . (!$disabled ? '' : ' disabled') . '">
<input type="checkbox"
Expand Down
Expand Up @@ -18,6 +18,7 @@
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;

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

0 comments on commit 39c2e11

Please sign in to comment.