I have a field on a custom entity that is an entity reference to a node. However when I select this field as a filter and expose it, it just acts like a numeric field instead of a reference field (only option is less than, greater than, equal to... etc).

How can I make this field act properly? I just want a drop down of options (only 32 nodes ever) to make filtering easy.

  • Last time I had the same issue there was nothing in core, the closest thing in contrib is this alpha module I think: drupal.org/project/entity_reference_exposed_filters. The form alter and manually loading the entities as options is a pretty good solution too
    – Clive
    Feb 8, 2018 at 20:49
  • I also just came across this: drupal.org/project/verf
    – Kevin
    Feb 8, 2018 at 21:17
  • Good find, just checked the code for the views filter and it's a lot better in verf
    – Clive
    Feb 8, 2018 at 21:19

1 Answer 1


I think there are many solutions but I resolved the same problem in the hook hook_form_alter() altering the form element type from textfield to select and populate the #option attribute:

  $options = _getOptions();
  $form['your_field'] = [
    '#type' => 'select',
    '#options' => $options,

Other solutions are appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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