Fixed
Project:
Views Reference Field
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Jan 2022 at 13:13 UTC
Updated:
28 Jul 2026 at 08:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
_shyHere is a patch to fix this issue. I added
@EntityReferenceSelectionplugin for support preselect options for the autocomplete field widget.Comment #3
finex commentedThank you, the patch works flawlessly.
Comment #4
scott_euser commentedApologies for missing this. I am just a bit nervous that this is risky as it seems quite likely that there may be cases where site editors have selected a View they are not allowed to select according to 'Preselect View Options'. I suppose it won't break things BUT it would then prevent resave e.g. of a node or paragraph.
Beyond that we just need test coverage + conversion to merge request to get this in.
Comment #5
scott_euser commentedNeeds also coordination in case #2922687: Allow inclusion of views by administrative tag(s) in select widget. is merged first to also add that restriction to autocomplete (could also be a separate follow-up issue though)
Comment #6
trackleft2It might be safer to move the configuration for this feature, to the field widget settings for the select widget. This approach would ensure that existing widgets (currently only the Select widget) continue to function properly while introducing this as a new option for the Autocomplete widget.
What are your thoughts?
Comment #7
scott_euser commentedHmmm it's a good suggestion.
I guess my worry is that choosing which views are available is probably comparably essential as choosing a vocabulary with a taxonomy reference field and DX might suffer hiding it.
Might anyways be simpler to add support for autocomplete then to handle the update hooks.
Comment #9
trackleft2I've added a proof of concept as Merge Request !82 for your consideration.
The merge request:
- Incorporates the patch from #2 but uses widget settings instead of field settings.
- Has an update function to move values from field config to field widget config
- Adds widget settings for both the select element and the autocomplete widget.
Comment #10
scott_euser commentedHmmm yeah I see how it would work, and thank you for spending the time on it. I think its a fairly big DX change though and I still worry about it then being more hidden.
Are there other features you feel are specific to the Select widget that justify the separation of controls from autocomplete vs select? Otherwise I can try to insist that any future new feature covers both, allowing us to keep the settings in the field settings (e.g. in #2922687: Allow inclusion of views by administrative tag(s) in select widget.)
If we do ultimately go down this route, we can sign-post that more controls can be found in the manage form display, but let's not do that yet until we get more of a direction decision (which I am not convinced is needed yet). If we are at a stalemate I can reach out to other maintainers in Drupal Slack to get opinions. Sorry - just nervous as its a very heavily used module
For anyone else reviewing, updated screenshot:
Manage form display with proposed change:
Manage field settings with proposed change:
Comment #11
scott_euser commentedFWIW:
Comment #13
trackleft2I've converted the patch in #2 to a merge request.
This seems to work, however, now the existing PHPUnit tests are failing.
See https://git.drupalcode.org/project/viewsreference/-/blob/8.x-2.x/tests/s...
Comment #14
scott_euser commentedThanks for all the work on this! Fixed it up a bit + added new test coverage that fails before this code and passes after.
Comment #16
scott_euser commentedHid the managed form display branch just to avoid future confusion (not delete of course in case ever revisiting UX).
Comment #19
scott_euser commentedRunning out of time this morning but hopefully that will resolve the test coverage. Could use a check from one of us here again to get an RTBC if so. Thanks!
Comment #20
scott_euser commentedPipeline green now yeah
Comment #22
scott_euser commentedThanks for the back and forth on this. The DX change to manage form display can be a follow-up, will leave the branch in case its ever useful; but good to actually fix the issue itself here.