2

Is there a select widget I can use instead of autocomplete for referencing entities? Right now I am using this in my baseFieldDefinitions function:

->setDisplayOptions('form', array(
    'type' => 'entity_reference_autocomplete',
    'settings' => array(
      'match_operator' => 'CONTAINS',
      'size' => 60,
      'placeholder' => '',
    ),
  ))

but I need to have a select widget instead. Any ideas?

3

I was able to change the widget from the field config page. The key used by drupal was options_select, so I updated the type to:

'type' => 'options_select'
  • note that the select widget has different settings (actually none I think), so make sure to update that as well. In general, to figure out what options you have, you can always create a field of the same type in the UI (or make it configurable), then export the created view/form display and convert the YAML type + settings back into PHP for your base field definition. – Berdir Nov 8 '16 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.