By vasike on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.4.x, 11.1.x
Introduced in version:
10.4.x, 11.1.0
Issue links:
Description:
A new Views Entity Reference filter plugin is now available for all entity reference fields:
- content entity reference with and without bundles.
- configuration entity reference
This filters the results based on the selected entity from the autocomplete or select list.
This filter is not used by default but can be opted into using hook_views_data_alter() like this:
/**
* 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';
}
Alternatively, contributed module views_core_entity_reference that will do that automatically for you.
Views Entity Reference filter demo
Select from available filters

Choose between select or autocomplete widgets

Configure the widget (example shows 'select')

Filters list after adding 3 examples referencing node, user, and configuration

See the views result
