This module opts-in to using the new Entity Reference filter provided by Drupal Core in this issue. It is therefore a very minimal module to help developers out.
Example use: Create an entity reference field between two node types like Projects and Reports. Create a Filter in a View to allow filtering Reports by Project:
Before: Numeric comparison in the filter only
After: Select or autocomplete by Project name
Aims of the module
- Opt entity reference fields in to using the new Entity Reference filter for common use cases
- Provide update hooks for older versions of the patch from this issue such as the use of the 'as a Reference filter' that was in place the last several months of that issue
- Let site builders choose which fields are switched, and make sure existing Views filters keep working when they are
- Automated test coverage to ensure the above works
The update path from older versions of patches is experimental. Try it out and contribute back features. When doing so please add to the Kernel Test.
How to use
Requires Drupal 10.4 or 11.1 and later, where the Entity Reference filter is part of Core. Install the module, then add or edit Views filters on your entity reference fields.
Choosing which fields are switched
Go to Structure > Views > Settings > Entity reference filters (/admin/structure/views/settings/entity-reference). The page lists each entity reference field, the filter it currently uses and the views that filter on it.
- Fields: every entity reference field uses the Entity Reference filter unless you select it to exclude it. You can switch to only using the fields you select.
- Base fields (coming soon) (fields an entity type defines in code, such as the owner of a custom entity): none are switched until you select them. Base fields that already have their own filter, such as the content author, are not listed.
Taxonomy term reference fields keep the taxonomy filter that Core already provides.
Existing filters
A filter saved for the numeric filter does nothing once its field uses the Entity Reference filter, and the other way around. To avoid views silently showing unfiltered results, when the module is installed or updated:
- Existing "Is equal to", "Is empty" and "Is not empty" filters that are not exposed are converted to the Entity Reference filter.
- Fields with any other existing filter (exposed filters, or operators such as "Is not equal to", "Is less than" or "Is between") keep their original filter and are listed as excluded on the settings page. Select the field there and re-add the filter when you are ready to switch it.
The status report shows an error for any filter that is not being applied. Check it after changing the settings and before uninstalling this module: filters created with the Entity Reference filter are not converted back.
Exposed filters and visible labels
This is how the filter in Core works, not something this module adds: an exposed Entity Reference filter lets anyone who can use the view look up the labels of the entities its reference method returns, through the select list or the autocomplete. For a user reference field that means the names of active users. Limit the bundles, or use a view as the reference method, when those labels should not be visible to everyone who can see the view.
Possible features that are not in place
- Provide an update hook to migrate away from this module to Core only [Postponed until the relevant Core issues are completed]
Planning for this module
This module is meant to be used until the following follow-ups to that issue are committed:
- #3458099: Views handler loading should respect configuration
- #3438054: Configurable views filters to allow for different widgets
This module is a good place to then provide a migration away from this module after which it can be uninstalled and removed.
Alternatives to using this module
Rather than using this module, you could also use the alter hook to opt-in in code. Existing filters on that field are not converted for you, so remove and re-add them afterwards:
/**
* Implements hook_views_data_alter().
*/
function MODULE_NAME_views_data_alter(&$data) {
// Use entity reference for the field 'field_test_target'.
$field_name = 'field_test_field';
$data['node__' . $field_name][$field_name . '_target_id']['filter']['id'] = 'entity_reference';
}
Project information
- Project categories: Content display, Developer tools
1,090 sites report using this module
- Created by scott_euser on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
Releases
Adds Drupal 12 compatibility. Automatic updates of existing "as a Reference" filters now preserve filter order, leave existing filters untouched, and apply to every view display rather than only the default.
Development version: 1.0.x-dev updated 4 Dec 2026 at 06:31 UTC
