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
- Minimal automated test coverage to ensure the above works
The update path from older versions of patches is expirimental. Try it out and contribute back features. When doing so please add to the Kernel Test.
How to use
Use a version of Core that contains the Entity Reference filter (currently 11.x and 10.4.x) or use an older version of Core along with an appropriate patch. The patch must match the final committed version. For now that is just the '3347343-10-3-x--comment-214-onwards--do-not-merge' branch in this issue.
Possible features that are not in place
- A settings page to decide which filters to opt-in rather than making assumptions
- 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 remove.
Alternatives to using this module
Rather than using this module, you could also use the alter hook to opt-in in code:
/**
* 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
803 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
Move from update to install hook for old patch conversion attempts
Development version: 1.0.x-dev updated 19 Apr 2025 at 09:58 UTC
