My Code looks like this:
$fields['color'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Color'))
->setDescription(t('The color of the fruit.'))
->setSetting('target_type', 'taxonomy_term')
->setSetting('handler', 'default:taxonomy_term')
->setSetting('handler_settings', ['target_bundles' => ['Color' => 'Color']])
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'author',
'weight' => -3,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'settings' => [
'match_operator' => 'CONTAINS',
'size' => 60,
'autocomplete_type' => 'tags',
'placeholder' => '',
],
'weight' => -3,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
I have a vocabulary with the name : 'Color'
I have 3 terms in it : 'Red', 'Yellow', 'Green'
The error I'm getting is this :
I'm trying to figure out what went wrong.
Color
tocolor
in['target_bundles' => ['Color' => 'Color']])
if you create a vocabulary callerColor
the machine name will becolor
NotColor
.