Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.3.6 Update released for Drupal core (10.3.6)! Release: Drupal 11.0.5 Update released for Drupal core (11.0.5)! Release: Drupal 10.2.9 Update released for Drupal core (10.2.9)! Release: Drupal 10.2.10 Update released for Drupal core (10.2.10)! Release: Drupal 10.3.7 Update released for Drupal core (10.3.7)! Release: Drupal 11.0.6 Update released for Drupal core (11.0.6)! Release: Drupal 10.3.8 Update released for Drupal core (10.3.8)! Release: Drupal 11.0.7 Update released for Drupal core (11.0.7)! Module Revived: Translation Management Tool 8.x-1.19 Module tmgmt updated after 7 months of inactivity (8.x-1.19). Usage Milestone: Account field split Module account_field_split crossed 10,000 active installs.

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';
}

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Jan 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.0-alpha3 Pre-release Jan 15, 2025