Custom Entity: define a view in entity reference field I defined a custom entity and for a entity reference field I want to set the view reference widget and a view/ display to be used instead of an autocomplete.

I tried many different settings - nothing worked. The latest version not working is:

$fields['user'] = BaseFieldDefinition::create('entity_reference')
  -&gt;setLabel(t('User account'))
  -&gt;setDescription(t('The user account this profile is connected to'))
  -&gt;setSetting('target_type','user')
  -&gt;setDisplayOptions('view', array(
    'label' =&gt; 'inline',
    'type' =&gt; 'string',
    'weight' =&gt; -6,
  ))
  -&gt;setDisplayOptions('form', array(
    'type' =&gt; 'views',
    'settings' =&gt; array(
      'handler_settings' =&gt; array(
        'view_name' =&gt; 'users_without_profile',
        'display_name' =&gt; 'entity_reference_1',
        'arguments' =&gt; []
      ),
      'weight' =&gt; 20
    )

  ))
  -&gt;setDisplayConfigurable('form', TRUE)
  -&gt;setDisplayConfigurable('view', TRUE);


For the form view setting I also tried

  -&gt;setDisplayOptions('form', array(
    'type' =&gt; 'views',
    'settings' =&gt; array(
      'view_name' =&gt; 'users_without_profile',
      'display_name' =&gt; 'entity_reference_1',
      'arguments' =&gt; [],
      'weight' =&gt; 20
    )
  ))


and

  -&gt;setDisplayOptions('form', array(
    'type' =&gt; 'entity_reference_autocomplete',
    'settings' =&gt; array(
        'handler' =&gt; 'views',
        'handler_settings' =&gt; array(
            'view_name' =&gt; 'users_without_profile',
            'display_name' =&gt; 'entity_reference_1',
            'arguments' =&gt; [],
        ),          
        'weight' =&gt; 20
    )
  ))


No success. Can somebody give me a hint?
The handler settings are part of the base field itself, rather than being a setting for the form display.

This should work:

$fields['user'] = BaseFieldDefinition::create('entity_reference')
  -&gt;setLabel(t('User account'))
  -&gt;setDescription(t('The user account this profile is connected to'))
  -&gt;setSetting('target_type','user')
  -&gt;setSetting('handler', 'views')
  -&gt;setSetting('handler_settings', [
    'view_name' =&gt; 'users_without_profile',
    'display_name' =&gt; 'entity_reference_1',
    'arguments' =&gt; [],
  ])
  ...