diff --git a/typo3/sysext/core/Classes/Configuration/Tca/TcaPreparation.php b/typo3/sysext/core/Classes/Configuration/Tca/TcaPreparation.php index d7c9a355cca835ed63366bd44fda2f42789284a2..27ab017d7d9ce23f6dc58bd3b43ae25a9210d90e 100644 --- a/typo3/sysext/core/Classes/Configuration/Tca/TcaPreparation.php +++ b/typo3/sysext/core/Classes/Configuration/Tca/TcaPreparation.php @@ -566,14 +566,33 @@ readonly class TcaPreparation private function removeCustomFieldLabels(array $showitemParts, array $fieldList): array { + if ($fieldList === []) { + return $showitemParts; + } foreach ($showitemParts as &$showItem) { - // Check if we deal with a field - if (!str_starts_with($showItem, '--div--') && !str_starts_with($showItem, '--palette--')) { - $parts = GeneralUtility::trimExplode(';', $showItem, true, 2); - // Just keep the first part => the fieldname in case field is defined in the $fieldList - if ($fieldList !== [] && in_array($parts[0], $fieldList, true)) { - $showItem = $parts[0]; + // Tabs keep their labels + if (str_starts_with($showItem, '--div--')) { + continue; + } + // Remove label of palette + if (str_starts_with($showItem, '--palette--')) { + $parts = GeneralUtility::trimExplode(';', $showItem, true, 3); + // Palette without label, continue. + if (count($parts) !== 3) { + continue; } + $paletteName = '--palette--;;' . $parts[2]; + if (in_array($paletteName, $fieldList, true)) { + $showItem = $paletteName; + } + continue; + } + // This must be a field. + $parts = GeneralUtility::trimExplode(';', $showItem, true, 2); + $fieldName = $parts[0]; + // Just keep the first part => the fieldname in case field is defined in the $fieldList + if (in_array($fieldName, $fieldList, true)) { + $showItem = $fieldName; } } return $showitemParts; diff --git a/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaPreparationTest.php b/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaPreparationTest.php index 895e4b59e99a25f0c58d5ff72bc0239343e46498..81f0bb97f644a7c83ac7b4f18e3491f7e0aeff15 100644 --- a/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaPreparationTest.php +++ b/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaPreparationTest.php @@ -855,6 +855,41 @@ final class TcaPreparationTest extends UnitTestCase --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended ', ]; + yield 'General palette with label already exists' => [ + [ + 'types' => [ + 'header' => [ + 'showitem' => ' + --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general, + --palette--;;headers, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:appearance, + --palette--;;frames, + --palette--;;appearanceLinks, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories, + categories, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended, + ', + ], + ], + ], + ' + --palette--;;general, + --palette--;;headers, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:appearance, + --palette--;;frames, + --palette--;;appearanceLinks, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories, + categories, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, + --palette--;;language, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, + --palette--;;hidden, + --palette--;;access, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes, + rowDescription, + --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended + ', + ]; yield 'Missing general palette' => [ [ 'palettes' => [