Review main Ready for review Quiet

97212[FEATURE] Introduce `EnumItemsProcessor` for TCA select fields

Elias Häußler CR 0 V 0 Hard +631 −0 updated 10/30/26, 08:53

Commit message

A new items processor `TYPO3\CMS\Core\DataHandling\EnumItemsProcessor`
has been added. It adds one item per case of a PHP enum to a TCA field
of type `select` and is registered via the TCA option `itemsProcessors`.
The enum itself is passed in the processor parameter `enum`.

Both backed and unit enums are supported. Backed enums use the backing
value as item value and the case name as label. Unit enums use the case
name as item value and label. Enums can, however, control the label by
implementing the interface `TYPO3\CMS\Core\Type\LabelledEnumInterface`.
Its method `getLabel()` is then used as item label. The returned string
can be a translation reference.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/12/97212/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/12/97212/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 4

Issues 1

Files 11

Review log 46

  1. Elias Häußler uploaded patch set 1 10/29/26, 10:03

  2. core-ci voted on patch set 1 V -1 10/29/26, 10:11 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112791

  3. Elias Häußler uploaded patch set 2 V -1 10/29/26, 10:12

  4. core-ci voted on patch set 2 V +1 10/29/26, 10:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112792

  5. Daniel Windloff commented on patch set 2 10/30/26, 06:31

    I would suggest implementing a dedicated TCA type for enums. Integrating this into the existing `select` type could lead to various side effects—for instance, when combined with `foreign_table` or when modifying the `items` array via configuration. From my perspective, using a PHP enum implies the intent to have a fixed set of immutable values. Being able to validate against this exact list would be highly advantageous, particularly for mapping in Extbase and for validation within the DataHandler. Furthermore, configuration would be significantly simplified, as one would generally only need to specify the type and a single parameter for the enum itself and the behavior for different option like default or nullable could be definied properly.
  6. Garvin Hicking commented on patch set 2 10/30/26, 08:53

    Reply Unresolved

    I agree, I think a distinct type will have advantages in the future and a cleaner "intent". Not sure yet how much redundancy this will bring, maybe we'll need to move parts of the select-type to a re-usable service or (yuc) using a trait. I really like the direction and plan!