Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Views Core Entity Reference

Security covered Under active development 873 sites

Part of the Views ecosystem · 280 projects

This module enables a more user-friendly way to filter content in Views by using the core Entity Reference filter. It allows you to filter entities by selecting or autocompleting related entity names instead of just using numeric IDs.

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

Ask your assistant about Views Core Entity Reference

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

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
4
Tracked since
Aug 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
1.0.0-alpha3 Pre-release 10–11 Jan 15, 2025
1.0.0-alpha2 Pre-release 10–11 Aug 7, 2024
1.0.0-alpha1 Pre-release 10–11 Aug 6, 2024
1.0.x-dev Dev 10–11 Aug 6, 2024