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)!

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 {
    return [
      'left' => t('Left'),
      'center' => t('Center'),
      'right' => t('Right'),
    ];
  }

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
5
First release
Mar 2026
Latest release
2 months ago
Release cadence
4 days
Stability
60% stable

Release Timeline

Releases

Version Type Release date
1.0.1 Stable Mar 30, 2026
0.0.0 Stable Mar 18, 2026
0.0.x-dev Dev Mar 18, 2026
1.0.x-dev Dev Mar 18, 2026
1.0.0 Stable Mar 16, 2026