Drupal is a registered trademark of Dries Buytaert
File Entity (fieldable files) 8.x-2.7 Minor update available for module file_entity (8.x-2.7). Field Group 4.1.0-alpha4 New alpha version released for module field_group (4.1.0-alpha4). OpenCulturas 3.0.5 Minor update available for distribution openculturas (3.0.5). Themespace 4.0.0 Major update available for module themespace (4.0.0). Recombee 2.0.7 Minor update available for module recombee (2.0.7). Permissions Analyzer 1.0.1 Minor update available for module permissions_analyzer (1.0.1). UaePass 1.0.0 Initial release available for module uaepass (1.0.0)! Sahaza Intranet 1.0.2 Minor update available for distribution sahaza_group_intranet (1.0.2). Session Limit Module session_limit crossed 1,000 active installs. Kint 2.3.4 Module kint updated after 6 months of inactivity (2.3.4).

This module allows you to easily define allowed values for fields by using an attribute on a method. You no longer need to configure this directly in field storage definitions.

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
4 months ago
Releases (12 mo)
5 ▲ from 0
Maintenance
Active

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