Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293561

Use the new 'entity_reference' Views filter in EntityViewsData::processViewsDataForEntityReference()

$
0
0

Problem/Motivation

Whoops! This was a big oversight at #3347343: Add Views EntityReference filter to support better UX for exposed filters. Although we got it right at #2640994: Fix label token replacement for views entity reference arguments when we added the new argument handler for entity_reference fields, and updated EntityViewsData::processViewsDataForEntityReference() to provide that automatically, we forgot this important step in #3347343.

So, even if you're on a modern version of Drupal that supports the better filter for entity reference fields, you have to do wonky crap like hook_views_data_alter() to turn it on for every single field where you need it.

Steps to reproduce

  1. Install Drupal 10.4.5.
  2. Add some entity reference fields to a custom entity type.
  3. Create a view of those entities, and try to filter by the entity reference field.
  4. You get a sad, numeric-only filter, not the happy new thing with autocomplete vs. select.

Proposed resolution

1 line change to EntityViewsData::processViewsDataForEntityReference():

        $views_field['filter']['id'] = 'entity_reference';

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293561

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>