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

cedric_a created an issue. See original summary.

jrockowitz’s picture

Couldn't this be accomplished with something like..

<script>document.write('<' + 'script src="//localhost/wf/webform/contact/share.js?' + location.search + '"></' + 'script>');</script>

jrockowitz’s picture

Status: Active » Needs review
cedric_a’s picture

I 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.

jrockowitz’s picture

Status: Needs review » Closed (won't fix)