Closed (fixed)
Project:
Views Reference Field
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 May 2017 at 11:59 UTC
Updated:
17 Dec 2018 at 20:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
Patrick Bauer commentedComment #3
Patrick Bauer commentedInside ViewsReferenceTrait.php in line 53 where the system retrieves the ViewDisplayIDs, its not using the newly chosen view to generate the options value but still the old original value after changing the view.
Comment #4
Patrick Bauer commentedI tried re-setting the options inside the getDisplayIds() function (which is called via Ajax to replace the DisplayID Form Element), but it didn't do anything.
After line 137:
Comment #5
Patrick Bauer commentedI've got a dirty quick fix which fixes it in our case. But I don't think this will work everywhere.
Comment #6
Patrick Bauer commentedUpdated version with a fix for the fix, still quick & dirty ;)
Comment #7
NewZeal commentedThanks for this patch. At this stage it appears not many people have tested it, nor it appears have many people recorded it as a problem. Given the amount of code involved in the patch I'm not sure if we can introduce it just yet.
Comment #10
recrit commented@New Zeal This still is an issue in 2.x. The ViewsReferenceTrait does not account for form state changes during the AJAX rebuild of the widget. If there are 2 views each with different display ID's the AJAX does not reset the form state input causing an "An illegal choice has been detected".
Example:
view01: displays = ["block"]
view02: displays = ["not_block", "grid"]
Save a node with the field set to view01.
Edit the node and do the following:
- Select "view02".
- Allow AJAX to populate displays list.
- Select "view01".
- RESULT: ERROR: "An illegal choice has been detected".
- REASON: The AJAX only updates display_id element's #options which leaves the form state values in an illegal combination of view id and display id. In this example: "view01", "not_block".
FIX:
The attached patch revamps the AJAX implementation.
This was loosely based on the address module's country AJAX refresh.
- Dynamic form changes while preserving the view_id to display_id relationship.
- Follows the form API so the hook_widget_form_alters() can be applied to the entire widget during the AJAX refresh.
- Fixes the above bug "An illegal choice has been detected".
Comment #11
recrit commentedComment #13
recrit commentedPatch #10 should be tested on viewsreference 8.x-2.x but it is not available in the test suite's custom options.
Comment #14
recrit commentedSwitched #parents to the correct #field_parents.
Comment #15
recrit commentedsame patch, just fixed misspelling in the file name
Comment #16
recrit commentedComment #18
seanbWas able to reproduce the issue and confirm the latest patch worked. Fixed some minor nits on commit (unused variables etc).
Nice work! Thanks.
Comment #20
rajab natshahThank you
Comment #22
jasonawantHi,
Here's a reroll of patch in #6 for 8.x-1.x version.
Comment #23
jasonawantPrevious patch is garbage. I'd really like to just go with the 2.x version if we can get a beta, or better yet a full release. See #3019753: Plan for Views Reference Field 2.x-1.0 release