Problem/Motivation
We have a contact form with a field that we're prepopulating via URL query/params -- but, when we set a default value for the field, that default value is pre-filled in the field even when the URL has query params meant to pre-fill the field.
I'll paste my webform YML in the first comment, to keep the issue summary clean. Example URL with query:
https://www.example.com/about-us/contact-us?contact=bioinformatics
(So, even with the URL like this and "prepopulate" enabled for the field, the default value, "Communications", is selected every time 😢)
rest of the issue summary template...
Proposed resolution
(Description of the proposed solution, the rationale behind it, and workarounds for people who cannot use the patch.)
Remaining tasks
(reviews needed, tests to be written or run, documentation to be written, etc.)
User interface changes
(New or changed features/functionality in the user interface, modules added or removed, changes to URL paths, changes to user interface text.)
API changes
(API changes/additions that would affect module, install profile, and theme developers, including examples of before/after code if appropriate.)
Data model changes
(Database or configuration data changes that would make stored data on an existing site incompatible with the site's updated codebase, including changes to hook_schema(), configuration schema or keys, or the expected format of stored data, etc.)
Release notes snippet
(Major and critical issues should have a snippet that can be pulled into the release notes when a release is created that includes the fix)
Original report by [username]
(Text of the original report, for legacy issues whose initial post was not the issue summary. Use rarely.)
Comment | File | Size | Author |
---|---|---|---|
#8 | 3122362-8.patch | 6.98 KB | jrockowitz |
| |||
#4 | 3122362-2.patch | 560 bytes | jrockowitz |
| |||
#4 | webform.webform.issue_3122362.yml | 4.47 KB | jrockowitz |
Comments
Comment #2
alisonSource of form "build":
Comment #3
alisonComment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe attached webform replicates this issue and the attached patch fixes this issue. The patch still needs test coverage to prevent any additional regressions.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #6
alisonHoly cow that was crazy fast -- I tried it out and it works PERFECTLY, whether I have the "prepopulate" enabled at the form level or the form field level (yay!).
👍⭐️
Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedYou can use the patch AS-IS but I still need to improve the test coverage to prevent this type of regression.
Comment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThis patch has better test coverage.
Comment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedSince the patch has even more test coverage, I committed it. Please download the latest dev release to review.
Comment #11
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #12
alisonThank you!