0

I have two webforms on my Drupal 8 website. When a user submits the first webform, I have the confirmation redirect set to a second webform. I would like to populate one of the fields in the second webform with one of the submitted values from the first form. I have it set up as two separate webforms as some users will by-pass the first form and go directly to the second webform where they can manually enter the content into the field I need populated. Any idea how I can achieve this?

Thanks

F

2

Ok I figured it out - for anyone else who comes across this question.

In the first Webform, I set the Confirmation URL to:

/form/my-form2?value=[webform_submission:values:element_key]

I've bolded the elements in the URL that you will need to adjust for your webforms.

This will result in redirecting the user from my first Webform to the second Webform (which is at the URL www.mydomain.com/form/my-form2) when they click the submit button. It will append ?value=[the value from the webform field] to the end of the URL.

Then in the second form in the field where I want this value to go, I have set the Default value for this field as

[current-page:query:value]

The word 'value' in the above can be anything, but it must match the id used in the URL from the first form.

And hey presto - it works!

F

  • You can simply use the webform setting "Allow all elements to be populated using query string parameters" so you don't have to set default values. I'd love to find a POST-based solution that doesn't expose submitted data in the URL, though. – nwellnhof Aug 22 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.