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

  1. Opt entity reference fields in to using the new Entity Reference filter for common use cases
  2. 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
  3. 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

  1. A settings page to decide which filters to opt-in rather than making assumptions
  2. 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:

  1. #3458099: Views handler loading should respect configuration
  2. #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';
}
Supporting organizations: 
Original development and maintenance

Project information

Releases