Are there any limitations for creating BaseFieldDefinitions from services?
If I try to add some fields from within a service called by hook_entity_base_field_info()
the code won't be executed - hence the fields are missing and can't be accessed by hook_form_node_form_alter etc.
→ No error or notice logged
The exact same code, placed directly into the hook, works like a charm...
Feel free to change the issue into a Bug report :)
function mymodule_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'node') {
$fields['additional_checkbox'] = \Drupal\Core\Field\BaseFieldDefinition::create('boolean');
$fields['additional_checkbox']
->setCustomStorage(TRUE)
->setLabel(t('Flag'))
->setDisplayOptions(
'form',
array(
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => 30,
)
)
->setDisplayConfigurable('form', TRUE);
return $fields;
}
}
Comments
Comment #10
cilefen commentedI am closing this support request because there have been no recent comments.
The Drupal Core issue queue is not the ideal place for support requests. Consider other sources of support.