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.
Issue fork custom_field-3539115
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
Comment #2
benstallings commentedComment #3
apmsooner commentedI 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.
Comment #4
benstallings commentedComment #5
benstallings commented@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.
Comment #6
benstallings commentednever mind my objections, @apmsooner, I will use your simpler approach. Thank you for the feedback!
Comment #8
benstallings commentedComment #9
benstallings commentedReady for review!
Comment #10
apmsooner commented@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
Comment #11
apmsooner commentedComment #12
benstallings commentedComment #13
apmsooner commentedThis is working as it should now and good to be merged.
Comment #16
apmsooner commentedComment #17
gaurav_manerkar commentedFatal 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