Add Views EntityReference filter to be available for all entity reference base fields

Created on 30 June 2024, 10 months ago

Problem/Motivation

✨ Continuation Add Views EntityReference filter to be available for all entity reference fields Active was getting overly complicated to get in in one issue. After discussion we opted to descope base fields and deal with non-base fields only first.

This issue is a follow-up to default entity reference base fields to use the entity_reference filter plugin provided in that issue.

Steps to reproduce

Attempt to use entity_reference for Comment Parent ID (an example entity reference base field from core)

Proposed resolution

Determine which entity reference base fields in Core do not provide viable alternatives and use the numeric filter (ie, many like uid already have viable alternatives)
Set the entity_reference field to be the default filter for those fields

Remaining tasks

For now everything (needs IS update)

User interface changes

Entity reference will be the default filter plugin for entity reference base fields

API changes

None

Data model changes

None

Release notes snippet

Base fields now default to using the Entity Reference Views filter plugin

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 13 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom scott_euser

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @scott_euser
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Fixes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    In (widely used) contrib Drupal Commerce I think the product_id, referencing the parent product from paroduct variations is a good example that should work with, once this issue is finished?

    // The product backreference, populated by Product::postSave().
        $fields['product_id'] = BaseFieldDefinition::create('entity_reference')
          ->setLabel(t('Product'))
          ->setDescription(t('The parent product.'))
          ->setSetting('target_type', 'commerce_product')
          ->setReadOnly(TRUE)
          ->setDisplayConfigurable('view', TRUE);

    Will this need changes in the Drupal Commerce implementation or will this work out of the box, once this is finished? (Otherwise I'll open a Drupal Commerce issue to keep track of this).

    The practical use case is to be able to filter by parent product in a list of Commerce Product Variations.

  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Actually looking back at ✨ Continuation Add Views EntityReference filter to be available for all entity reference fields Active I think this is outdated sorry! Because actually ✨ Configurable views filters to allow for different widgets Active will allow you to decide for whatever field whether you use entity reference or some other filter handler.

Production build 0.71.5 2024