Review main Merged

94815[BUGFIX] Respect type-specific Page TSconfig labels

Can Adrian Karadag CR +2 V +2 Hard +272 −0 updated 07/24/26, 07:13

Commit message

BackendUtility::getProcessedValue() reads the Page TSconfig section
"TCEFORM.<table>.<field>." when resolving select item labels, but
ignores its "types.<type>." sub-section. Backend previews built on
RecordFieldPreviewProcessor therefore render the plain TCA item
label - or the raw value, if the item exists through the override
only - while the edit form renders the configured one.

FormEngine already solves this twice, both times the same way: strip
"types." from the field configuration and overlay the matching type
section on top of it, see PageTsConfigMerged and
FormEngineUtility::getTCEFORM_TSconfig(). The record type itself is
determined by BackendUtility::getTCAtypeValue(), which additionally
covers type fields pointing to a foreign schema, array type values
and sub schema validation.

Determining the type inline from the record row would be shorter,
but duplicates existing logic and resolves the wrong value for
tables whose type points to a field in a foreign schema. Using the
type section as the field configuration instead of merging it would
be simpler, but drops everything configured on field level, for
instance altLabels.

Both established patterns are reused instead: getTCAtypeValue() with
the fallback skipped, as FormEngineUtility does, so an undefined
type leaves the field configuration untouched, and
ArrayUtility::mergeRecursiveWithOverrule() after removing "types.",
as PageTsConfigMerged does.

Select item labels in backend previews now match the edit form for
type-specific TCEFORM overrides, while field level configuration
keeps applying. Functional tests cover an added item, an overridden
label on a table other than tt_content, and the field level
configuration surviving for a typed record.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Markus Klein +1
    • Can Adrian Karadag +1
  • Verified V +2 Done
    • Benni Mack +2
    • Can Adrian Karadag +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 1722

  1. Can Adrian Karadag uploaded patch set 1 07/17/26, 14:15

  2. Benni Mack commented on patch set 1 07/17/26, 14:20

    BackendUtility.php:1322

    CType looks very tt_content specific, it should also work for other types of other DB tables.
  3. Benni Mack voted on patch set 1 CR -1 07/17/26, 14:20

  4. core-ci voted on patch set 1 V -1 07/17/26, 14:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104887

  5. Can Adrian Karadag uploaded patch set 2 CR -1 V -1 07/22/26, 11:37

  6. Can Adrian Karadag commented on patch set 2 07/22/26, 11:40

    BackendUtility.php:1322 Reply

    @benni@typo3.org you're right, i updated the commit and also added a second test which also test for non tt_content table
  7. Can Adrian Karadag uploaded patch set 3 07/22/26, 11:43

  8. core-ci voted on patch set 2 V -1 07/22/26, 11:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105163

  9. core-ci voted on patch set 3 V +1 07/22/26, 11:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105164

  10. Markus Klein updated the commit message in patch set 4 V +1 07/22/26, 13:21

  11. core-ci voted on patch set 4 V +1 07/22/26, 13:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105183

  12. Stefan Bürk commented on patch set 4 07/23/26, 14:25

    Thanks for tackling this — the analysis is right and the fix is in the right place: RecordFieldPreviewProcessor already passes uid/pid/row, so the missing piece really is the "types." evaluation in getProcessedValue(). Two things need to change before this can go in: the type-specific TSconfig must be merged *over* the field TSconfig instead of replacing it (this drops altLabels/removeItems for typed records today), and the record type should be resolved via BackendUtility::getTCAtypeValue() instead of reading the row directly. Details inline. I verified the first point locally with an additional functional test: it passes on the parent commit and fails with this patch set.

    BackendUtility.php:1321

    getTcaSchema() returns ?TcaSchema, and isset() is false for null, so a table without a schema falls through to $schema->getSubSchemaTypeInformation() and raises an \Error — which catch (\Exception) does not catch. Reachable when $theColConf is passed explicitly (the @internal FlexFormValueFormatter path) for a table without TCA schema. PHPStan runs at level 5 here, so nullable method calls are not reported and CI stays green. Relying on whether $schema happens to be defined by the branch ~70 lines above is fragile in itself.

    BackendUtility.php:1326

    Please use BackendUtility::getTCAtypeValue($table, $fullRow, true) — it lives in this very class (line 528) and is exactly what FormEngineUtility::getTCEFORM_TSconfig() uses for this merge. Reading the pointer field off the row misses what that helper handles: * foreign-pointer types ('type' => 'localfield:foreignfield'): getSubSchemaTypeInformation()->getFieldName() returns the *pointer* field, so $fullRow[$fieldName] is a foreign uid and the lookup key is wrong, * array type values (selectCheckBox), * hasSubSchema() validation and the fallback semantics.

    BackendUtility.php:1334

    This replaces the field TSconfig instead of overlaying the type section on top of it, which drops everything configured on the field level. TCEFORM.tt_content.my_field { altLabels.option1 = Global label types.textmedia.addItems.option4 = Extra } For a textmedia record with value "option1", main currently resolves "Global label"; with this patch altLabels. is gone and the plain TCA item label wins — a regression on a path that works today, and it also diverges from the edit form, which is the parity this issue asks for. I confirmed this with a functional test on test_table: TCEFORM.test_table.select_field { altLabels.foo = Field level label types.special { addItems.bar = Type specific item } } with a record record_type=special, select_field=foo. On the parent commit it resolves "Field level label"; with patch set 4 it resolves "Default label" (the plain TCA item). Core does this merge in two places, both overlay + strip "types.": * Form/FormDataProvider/PageTsConfigMerged.php:50-58 (ArrayUtility::mergeRecursiveWithOverrule()) * Form/Utility/FormEngineUtility.php:152-155 (array_replace_recursive()) Suggested shape for the whole block, which also resolves the other points below: if (isset($pageTsConfig['TCEFORM.'][$table . '.'][$col . '.']) && is_array($pageTsConfig['TCEFORM.'][$table . '.'][$col . '.'])) { $columnTsConfig = $pageTsConfig['TCEFORM.'][$table . '.'][$col . '.']; $typeSpecificTsConfig = $columnTsConfig['types.'] ?? []; unset($columnTsConfig['types.']); $recordType = self::getTCAtypeValue($table, $fullRow, true); if ($recordType !== null && is_array($typeSpecificTsConfig[$recordType . '.'] ?? null)) { ArrayUtility::mergeRecursiveWithOverrule($columnTsConfig, $typeSpecificTsConfig[$recordType . '.']); } } No try/catch, no schema juggling, and "types." no longer leaks into SchemaLabelResolver. With this shape both of your tests (with the CType adjustment noted further down) and the regression test above are green on sqlite and mariadb.

    BackendUtility.php:1336

    An empty catch that swallows the exception (with an unused $e and a blank body) is not something we want here. The explicit guard exists and is used in this class at line 533 and in DataHandler.php:8253: if ($schema->supportsSubSchema()) { ... } With getTCAtypeValue() (see above) the try/catch disappears entirely.

    BackendUtilityTest.php:943

    CType "special" is not a declared type in tt_content TCA. The test only passes because the type value is read raw from the row; with proper resolution via getTCAtypeValue(..., skipFallback: true), hasSubSchema('special') is false and the override would not apply — same as in the edit form. I tried the suggested implementation locally: this test then fails with "specialValue" (the raw value), while it passes unchanged when the record uses CType "textmedia". Please use a real CType (e.g. "textmedia"), which also matches the scenario from the issue.

    BackendUtilityTest.php:1003

    Nice that this covers a non-tt_content table. What is still missing is the case that guards the merge semantics: a field that has *both* a field-level entry (e.g. altLabels.foo) and a types.<type>. section — the field-level entry must survive for a typed record. That test would have caught the replace-instead-of-merge issue above. A foreign-pointer type table and removeItems inheritance would be worth adding too.
  13. Stefan Bürk commented on patch set 4 CR -1 07/23/26, 14:28

    BackendUtility.php:1321 Reply

    unresolve (resolved was an error)

    BackendUtility.php:1326 Reply

    unresolve (resolved was an error)

    BackendUtility.php:1334 Reply

    unresolve (resolved was an error)

    BackendUtility.php:1336 Reply

    unresolve (resolved was an error)

    BackendUtilityTest.php:943 Reply

    unresolve (resolved was an error)

    BackendUtilityTest.php:1003 Reply

    unresolve (resolved was an error)
  14. Stefan Bürk commented on patch set 4 07/23/26, 14:30

    on it ...
  15. Stefan Bürk uploaded patch set 5 CR -1 V +1 07/23/26, 14:54

  16. Stefan Bürk commented on patch set 4 07/23/26, 14:55

    BackendUtility.php:1321 Reply

    Done

    BackendUtility.php:1326 Reply

    Done

    BackendUtility.php:1334 Reply

    Done

    BackendUtility.php:1336 Reply

    Done

    BackendUtilityTest.php:943 Reply

    Done

    BackendUtilityTest.php:1003 Reply

    Done
  17. Stefan Bürk commented on patch set 5 07/23/26, 14:56

    Reply

    Done
  18. core-ci voted on patch set 5 V +1 07/23/26, 15:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105255

  19. Markus Klein voted on patch set 5 CR +1 07/23/26, 15:51

  20. Can Adrian Karadag commented on patch set 5 CR +1 V +1 07/24/26, 04:49

    thank you for improve my patch, i tested it and everything works as expected
  21. Benni Mack commented on patch set 5 CR +2 V +2 07/24/26, 07:13

    Reply

    Done
  22. Benni Mack merged patch set 6 07/24/26, 07:13