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). OpenAI Provider 1.2.4 Minor update available for module ai_provider_openai (1.2.4). mosparo Integration 1.0.5 Minor update available for module mosparo_integration (1.0.5). Webform Booking 1.2.0 Minor update available for module webform_booking (1.2.0). Labor time tracker 1.0.0 Initial release available for module labor_time_tracker (1.0.0)! Phrase TMS Integration for TMGMT 8.x-1.29 Minor update available for module tmgmt_memsource (8.x-1.29). Intercept 2.0.27 Minor update available for module intercept (2.0.27). Domain Extras 3.0.4 Minor update available for module domain_extras (3.0.4). 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