Similar to how you can reference a user or a node, I would like to reference a custom entity:
$fields['department_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Department'))
->setDescription(t('Select the department for this business.'))
->setSettings(array(
'target_type' => 'department_register'
))
->setSetting('handler', 'default')
->setDisplayOptions('view', [
'label' => 'inline',
'type' => 'department',
'weight' => -10,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'settings' => [
'match_operator' => 'CONTAINS',
'match_limit' => 10,
'size' => 60,
'placeholder' => ''
],
'weight' => -10,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
Where 'target_type' => 'department_register' is my custom department entity
I'm stuck in how to connect my department entity. How can I setup the right plugin configuration for my autocomplete form field which should be able to select the name of the department?