Closed (fixed)
Project:
Webform
Version:
6.x-3.9
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
17 Mar 2011 at 05:51 UTC
Updated:
12 Jan 2012 at 22:52 UTC
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
Comment #1
quicksketchHow 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.Comment #2
Pillhuhn commentedThe 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!
Comment #3
quicksketchYou 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".
Comment #4
Pillhuhn commentedAwesome. 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.
Comment #5
quicksketchComment #7
trevorbradley commentedIs "destination" actually documented anywhere? I only found this out through scrounging the support requests. :)
Comment #8
malancheril commentedThis 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?
Comment #9
lanexa commentedhave 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.
Comment #10
lanexa commentedI resolved this by implementing ajax for the form submission - works like a charm!