I have a custom entity ‘myentity’ with some fields, and one of them is a taxonomy field with the next definition:
$fields['colors'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Colors'))
->setDescription(t(''))
->setRequired(FALSE)
->setSetting('target_type', 'taxonomy_term')
->setSetting('handler', 'default:taxonomy_term')
->setSetting('handler_settings',
array(
'target_bundles' => array(
'colors' => 'colors'
)))
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => 0,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
It works good and I can use my entity without any problem. But there is a problem:
FieldStorageConfig::loadByName('myentity','colors');
returns NULL.
I don’t know why, but I think It should returns my field definition.
Because It doesn’t work, I have tried with "drush upe" (with this module) that let you ensure the field definition is right, but without success.