Needs work
Project:
Drupal core
Version:
main
Component:
typed data system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Nov 2021 at 02:09 UTC
Updated:
12 Oct 2026 at 16:36 UTC
Jump to comment: Most recent
Comments
Comment #2
andypost10.0 requires 8.1
Comment #3
dpiForm field/widget side @ #3249599: Add support for PHP 8.1 Backed Enums in Select, Checkboxes, Radio elements
Comment #5
duadua commentedComment #6
duadua commentedComment #7
andypostThere's no patch or MR to review
Comment #9
andypostComment #10
duadua commentedComment #11
duadua commentedComment #12
dieterholvoet commentedComment #14
dwwLove this. But curious how it would work in the Field UI. Is the idea that if a field uses this to manage allowed values, that those parts of the UI where you define the values and labels would disappear or something?
Comment #15
claudiu.cristeaComment #17
aaronmchalePHP 8.3 added Backed Enums, which opens up the possibility of key/value enums.
So, if we supported Backed Enums, then we essentially have the equivalent of a function which returns an array for the keys/values.
Backed Enums can have methods, like classes, the Enum class could define a
label()method which returns the enum value usingTranslatableMarkup.This opens up another possibility where the Enum could have methods that the field could make use of for other things (not sure what yet), but there's potential!
Here's an example of a
Statusenum that I built to use as the allowed values of alist_stringbase field.If list fields supported Backed Enums, I wouldn't need the
options()method.But you can see the potential here!