Hello,

is it possible to have Webform redirect the user to the previous page (originating page) after submitting a webform?

In my case, I created a personal contact form that should be accessible from a few different nodes from my site. So if someone accesses the contact form from page A, I would like to redirect this user back to page A after submitting the form, whereas someone accessing the same contact form from page B, would be redirected to page B after submitting the form.

Is there any way to do this? I hope all of this makes sense.

Thanks!

Comments

quicksketch’s picture

How are you making the form "accessible from a few different nodes"? Depending on how you're doing this (in a block, or by a link) the answer may differ. Usually you can accomplish this by simply setting a destination value in your URL, such as <a href="/node/10?destination=node/1">Fill out survey!</a>, where "10" is the Webform node and "1" is the originating node.

Pillhuhn’s picture

The webform is accessible via links. So how would I link back to node/1 after submitting the form when I use the link from your example? (Sorry I am really new to Drupal and Website programming...)

Thanks so much for your help!

quicksketch’s picture

Category: feature » support

You don't need to link back to node/1 at all. When you create the link to node/10, add ?destination=node/10 in your href, then Drupal will redirect the user back to node/10 after the form is completed at node/1. You can actually do this in any form in all of Drupal, the user will be sent to wherever "destination" is when any form on the page is filled out. You should also make sure that your confirmation message is shown as a message and not a confirmation page. In which case you should set the redirect option under node/x/webform/configure in your Webform to "No redirect".

Pillhuhn’s picture

Awesome. Thank you so much. This made my day (sometimes it is the little things... :)
That was what I was looking for and shows me that there is a LOT to learn for me.

quicksketch’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

trevorbradley’s picture

Is "destination" actually documented anywhere? I only found this out through scrounging the support requests. :)

malancheril’s picture

This doesn't seem to work in my case. I have enabled a webform as a block and embedded it inside a panel. I put a message in the confirmation message window and selected "No redirect (reload current page)". When the form is submitted, instead of displaying the message and reloading the page, it reloads the window with the webform's page view and displays the message there. Any idea what I'm doing wrong?

lanexa’s picture

have a similar situation to malancheril - have webform as a block and upon submission, the actual webform *page* is reloaded and what I want reloaded is the page that contains the webform block.

lanexa’s picture

I resolved this by implementing ajax for the form submission - works like a charm!