I finally found a way to get it to work after digging through the code for the EntityReferenceAutocompleteWidget
. To enable automatic creation, I needed to edit the handler settings. Here's my code:
$fields['client'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Client'))
->setSettings(array(
'target_type' => 'client',
'handler' => 'default',
'handler_settings' => array( // Added
'auto_create' => TRUE // Added
)
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => 60,
'placeholder' => ''
),
'weight' => 0
))
->setRequired(TRUE);