Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Frenske on
Hello,
I've a custom module with a custom content type, with the field defined below. It has a allowed_values_function, so I can specify the option for this selectbox. But this function is not called when I add new content. Even worse, I don't see the category field.
langcode: nl
status: true
dependencies:
module:
- node
- options
id: node.field_custommodule_category
field_name: field_custommodule_category
entity_type: node
type: list_string
settings:
allowed_values: { }
allowed_values_function: 'custommodule_category_allowed_values'
module: options
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
I've added the callback function In the 'custommodule.module' file.
function custommodule_category_allowed_values(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &$cacheable = TRUE){
return array('test1', 'test2');
}
Expected behavior: When I add a new node of this type, I expect a 'category' selectbox with values 'test1'+'test2'.
Thanks