Drupal is a registered trademark of Dries Buytaert
seven 2.0.0-beta6 New beta version released for theme seven (2.0.0-beta6). seven 1.0.1-beta1 First beta version released for theme seven (1.0.1-beta1). swiper_formatter 2.1.1 Minor update available for module swiper_formatter (2.1.1). solo 1.0.31 Minor update available for theme solo (1.0.31). raven 7.3.7 Minor update available for module raven (7.3.7). localgov_publications 1.1.3 Minor update available for module localgov_publications (1.1.3). localgov_base 2.3.4 Minor update available for theme localgov_base (2.3.4). proc 10.1.106 Minor update available for module proc (10.1.106). localgov_events 3.2.4 Minor update available for module localgov_events (3.2.4). localgov_core 3.1.1 Minor update available for module localgov_core (3.1.1). cloudflare_purge 3.0.4 Minor update available for module cloudflare_purge (3.0.4). paragraphs_bundles 1.0.16 Minor update available for module paragraphs_bundles (1.0.16). localgov_search_solr 1.2.1 Minor update available for module localgov_search_solr (1.2.1). lms 1.1.14 Minor update available for module lms (1.1.14). pets_clinic 1.0.6 Minor update available for theme pets_clinic (1.0.6). add_child_page 3.2.1 Minor update available for module add_child_page (3.2.1). cmlexchange 8.x-1.22 Minor update available for module cmlexchange (8.x-1.22). flowdrop 1.1.0 Minor update available for module flowdrop (1.1.0). add_child_page 3.1.2 Minor update available for module add_child_page (3.1.2). add_child_page 3.2.0 Minor update available for module add_child_page (3.2.0).

This module simplifies the process of using a method for a field's allowed values.

Normally, you have to set the method directly in the field’s StorageConfig — either in the configuration file or via hook_entity_field_storage_info_alter().
After installing this module, you can simply add the AllowedValuesFunction attribute to the corresponding method and don’t have to worry about anything else.

Example:

  #[AllowedValuesFunction('node', 'field_headline_alignment')]
  #[AllowedValuesFunction('paragraph', 'field_subheadline_alignment')]
  public static function subheadlineAlignmentAllowedValues(FieldStorageDefinitionInterface $definition, ?FieldableEntityInterface $entity = NULL): array {
    $translation_args = [
      'context' => 'subheadline alignment',
    ];

    return [
      'left' => t('Left', $translation_args),
      'center' => t('Center', $translation_args),
      'right' => t('Right', $translation_args),
    ];
  }

Post-Installation

After installation create a class in one of your custom modules and add the method that provides the allowed values for a field. Add the attribute AllowedValuesFunction to the method.

Activity

Total releases
1
First release
Mar 2026
Latest release
1 day ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
1.0.0 Stable Mar 16, 2026