Problem/Motivation
The problem I faced was : how to access query parameters from the parent (embeding) page in the embeded webform (to prepopulate fields). In other terms, how to sync query parameters from the page to the iframe.
Proposed resolution
The solution I came to was to provide a different version of the share.js script using a new route. The new JS script gets query parameters and adds them to the iframe 'src' attribute.
I share my solution as a separate module instead of a patch, because I'm not sure it should be included in the Webform Share module.
Here is the module : https://github.com/CedricAlb/webfom_share_params
Remaining tasks
Discuss here to evaluate if it should be integrated to the Webform Share module
Comments
Comment #2
jrockowitz commentedCouldn't this be accomplished with something like..
<script>document.write('<' + 'script src="//localhost/wf/webform/contact/share.js?' + location.search + '"></' + 'script>');</script>Comment #3
jrockowitz commentedComment #4
cedric_aI tested your idea which I like because it could save us to use a regex... it's working when I just use the suggested script to embed a form but I faced caching issues (query parameters won't update in the iframe src after first display). I'll do more testing and will report my fidings here in the next days.
Comment #5
jrockowitz commented@see #3209749: Webform Share Script share.js missing Cacheable Dependency for distinct webform and node rendering
Comment #6
jrockowitz commentedI think my suggestion resolves this issue and we should focus on #3209749: Webform Share Script share.js missing Cacheable Dependency for distinct webform and node rendering