Problem/Motivation

When an entity reference subfield is placed on a custom field, the only filter types available in Views are plain text entry and autocomplete. VERF module provides a dropdown (select) input for entity reference fields but is not compatible with custom_field.

Steps to reproduce

Install custom_field and verf. Add an entity reference directly to an entity and also to a custom field, and populate both with data. Make a View and go to add filters -- you will see a VERF option for the direct entity reference field, but the only options for the subfield will be text entry and autocomplete.

Proposed resolution

Add a custom Views filter for entity reference fields based on VERF and use that instead of the text option.

Remaining tasks

Make a MR and test it.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

benstallings created an issue. See original summary.

benstallings’s picture

Issue summary: View changes
apmsooner’s picture

Version: 4.0.x-dev » 3.1.x-dev

I don't think we need that module as a dependency. If this is just a views filter than we can create a custom version of that for our needs. We would just need to create that here: https://git.drupalcode.org/project/custom_field/-/tree/3.1.x/src/Plugin/... and modify the filter type here: https://git.drupalcode.org/project/custom_field/-/blob/3.1.x/custom_fiel...

I can take a look at it when I get more time but open to patches if you wanna take a stab at it first.

benstallings’s picture

Issue summary: View changes
benstallings’s picture

@apmsooner you make a good point that we could just add a custom filter. My thinking was that since 9x as many sites are already using VERF as are using Custom Field, and since Custom Field already has 5 submodules including integrations with GraphQL and Linkit, this could just be one more submodule providing an integration.

benstallings’s picture

never mind my objections, @apmsooner, I will use your simpler approach. Thank you for the feedback!

benstallings’s picture

Title: Provide support for Views Entity Reference Filter (VERF) » Provide a dropdown/select input for entity reference filters
Issue summary: View changes
benstallings’s picture

Assigned: benstallings » Unassigned
Status: Active » Needs review

Ready for review!

apmsooner’s picture

Status: Needs review » Needs work

@benstallings,

Thanks for your work on this! Please just fix the new phpcs and phpstan warnings introduced from this code for now and I'll try to do a full review as soon as I can get to it.

Thanks

apmsooner’s picture

Title: Provide a dropdown/select input for entity reference filters » Views: Provide a dropdown/select input for entity reference filters
benstallings’s picture

Status: Needs work » Needs review
apmsooner’s picture

Status: Needs review » Fixed

This is working as it should now and good to be merged.

apmsooner’s picture

Status: Fixed » Closed (fixed)
gaurav_manerkar’s picture

Fatal error:

Type of Drupal\custom_field\Plugin\views\filter\CustomFieldEntityReference::$selectionPluginManager must not be defined (as in class Drupal\views\Plugin\views\filter\EntityReference) in /var/www/html/docroot/modules/contrib/custom_field/src/Plugin/views/filter/CustomFieldEntityReference.php on line 23