Fix select2 widgets rendering empty values in display mode when called from an easyform action#6
Open
chiruzzimarco wants to merge 1 commit intomtneersfrom
Open
Conversation
…d from an easyform action
alecpm
requested changes
May 2, 2024
alecpm
left a comment
There was a problem hiding this comment.
I don't like that this fix changes the value stored in the request during submit processing, especially since it's converting it to a value that isn't easily serializable in a widget if there's e.g. a validation exception on another field. It would be better to fix the specific issue which is the display mode rendering of the widget in the specific DummyFormView context. Perhaps a custom widgetTemplate directive that specifies the view class? I also. don't love that this fix lives in collective.easyform. I think we should try to register a custom display widget or widgetTemplate for the specific view class somewhere in the mtneers_shared package instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to Mountaineers issue #3991.
I think the root cause for this issue relies on plone.app.z3cform.
When the form is submitted selected values for select2 widgets are stored in the request form as strings, but the
Select2Widgetextractmethod is not doing any kind of validation on the request input to ensure this is converted to a list like z3c.form is doing on theSequenceWidget.Thus when the
DisplayValuemethod is called it expects to iterate on a list, but it will instead iterate on a string and raiseLookupErrors which are ignored.This "hacky" solution is the best thing i could find without the need to edit directly z3c.form or plone.app.z3cform code.