Drupal is a registered trademark of Dries Buytaert
cms 2.1.3 Update released for Drupal core (2.1.3)! drupal 10.5.11 Update released for Drupal core (10.5.11)! drupal 11.3.11 Update released for Drupal core (11.3.11)! drupal 11.2.13 Update released for Drupal core (11.2.13)! drupal 10.6.10 Update released for Drupal core (10.6.10)! cms 2.1.2 Update released for Drupal core (2.1.2)! drupal 11.1.10 Update released for Drupal core (11.1.10)! drupal 10.5.10 Update released for Drupal core (10.5.10)! drupal 10.4.10 Update released for Drupal core (10.4.10)! drupal 11.2.12 Update released for Drupal core (11.2.12)! drupal 11.3.10 Update released for Drupal core (11.3.10)! drupal 10.6.9 Update released for Drupal core (10.6.9)! drupal 10.6.8 Update released for Drupal core (10.6.8)! drupal 11.3.9 Update released for Drupal core (11.3.9)! drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)!

enum_field

339 sites Security covered
View on drupal.org

This module allows you to create List fields (integer/string) that get their allowed values from a PHP enum class. It also provides shortcuts to easily extract enum instances from field items and field item lists, for use in custom code:

$entity->get('field_some_enum')->enum
$entity->get('field_some_enum')->enums()

Core issue

This module will become partially obsolete once #3249600: Add support for PHP 8.1 Enums as allowed values for list_* field types lands. The only difference will be the above mentioned possibility to get the enum instance(s) in custom code.

Post-Installation

Create a new field of type Enum (text) or Enum (integer), set the enum class that should be referenced and use it like any other field.

Similar projects

  • Taxonomy Enum: also provides a field type for working with PHP enums, but this one automatically syncs all enum cases with taxonomy terms

Activity

Total releases
4
First release
Aug 2025
Latest release
1 month ago
Release cadence
87 days
Stability
100% stable

Release Timeline

Releases

Version Type Release date
1.3.0 Stable Apr 24, 2026
1.2.0 Stable Nov 27, 2025
1.1.0 Stable Nov 14, 2025
1.0.7 Stable Aug 6, 2025