Commit a8913dbe authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer
Browse files

[BUGFIX] Show correct value in translated single select + checkboxes

If the TCA option "l10n_mode" is set to "exclude", the selected field
in localised elements is wrong when using this option in conjunction
with "l10n_display" => "defaultAsReadonly" in a select single element.

In this case the variable $parameterArray['itemFormElValue'] seems to be
a string, not an array as expected in SelectSingleElement.php.

This patch adds a check for the array / string, as well as the
same behaviour for the checkbox.

Resolves: #76785
Resolves: #77257
Resolves: #84997
Resolves: #82843
Releases: master, 9.5
Change-Id: Ied0708dc378d73a8131791b28ebe1c61555c52aa
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63722


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Riccardo De Contardi's avatarRiccardo De Contardi <erredeco@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent 8b55ee29
......@@ -78,8 +78,14 @@ class SelectCheckBoxElement extends AbstractFormElement
$selItems = $config['items'];
if (!empty($selItems)) {
// Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
$itemArray = array_flip($parameterArray['itemFormElValue']);
// Get values in an array (and make unique, which is fine because there can be no duplicates anyway)
// In case e.g. "l10n_display" is set to "defaultAsReadonly" only one value (as string) could be handed in
if (is_array($parameterArray['itemFormElValue'])) {
$itemArray = $parameterArray['itemFormElValue'];
} else {
$itemArray = [(string)$parameterArray['itemFormElValue']];
}
$itemArray = array_flip($itemArray);
// Traverse the Array of selector box items:
$groups = [];
......
......@@ -128,8 +128,13 @@ class SelectSingleElement extends AbstractFormElement
$selectedValue = '';
$hasIcons = false;
// In case e.g. "l10n_display" is set to "defaultAsReadonly" only one value (as string) could be handed in
if (!empty($parameterArray['itemFormElValue'])) {
$selectedValue = (string)$parameterArray['itemFormElValue'][0];
if (is_array($parameterArray['itemFormElValue'])) {
$selectedValue = (string)$parameterArray['itemFormElValue'][0];
} else {
$selectedValue = (string)$parameterArray['itemFormElValue'];
}
}
foreach ($selectItems as $item) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment