Closed (fixed)
Project:
Webform
Version:
5.x-2.2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
20 Oct 2008 at 07:15 UTC
Updated:
11 Jul 2010 at 15:36 UTC
I have attached my webform inside a block. When the form is submitted I would like people to be redirected to the page they are on, as if they had never left.
at the moment i've tried this in the addition processing area:
[code]
$alias = drupal_get_path_alias($_GET['q']);
$node->webform['confirmation'] = 'internal:' . $alias;
[/code]
It's just taking me to the webform's url.
Any help would be much appreciated cheers.
Comments
Comment #1
quicksketchIf you don't enter a confirmation message at all, the user is redirected back to the webform URL. It sounds though that you're doing something unusual though, such as the Webform being displayed in a block?
Comment #2
jptarantoYes that's right the webform is displayed in a block (it appears as a javascript popup) - so I would like to skip redirecting to the url of the form and instead keep them on the same page.
Possible?
Comment #3
quicksketchHmm, well you can use the Additional Processing code to make the Webform redirect anywhere you want, but finding the originating URL could be a trick. See http://drupal.org/node/257100 for a description on how to set a custom URL redirection.
Comment #4
wansinn commentedI was sitting on the same issue now since hours and I found a strange but working solution:
the problem is that if i only redirect the form with "$node->webform['confirmation']="node/thisnodesid" (in the additional processing) i will be redirected "back" to the node where the webform is included as block (thats what i want) but as soon as the validation is not correct i will be redirected to the node of the webform (and thats bullshit because we want to stay in the node where the webform is included as block)
The solution is javascript:
Just change the action of the form with Javascript! This will redirect you to the node you want but the webform-functionality is still working.
Example:
First in the (maybe custom) "node.tpl.php" Insert a line that fills a session variable:
Then set the confirmation redirect in the "additional processing" of the webform edit:
At last in the (maybe custom) "block.tpl.php" insert following javascript AFTER printing the block content (print $block->content):
...
...
This will change the forms action and everything is fine ;)
I hope this will help anyone being confrontated with the problem as me ;)
Why all this webform in a block?
Because I was designing a ContentType with CCK and I wanted to implement a static form (which should have been a webform because of the submission workflow) in the node of the contenttype. So I decided to take the Field "blockreference" to include the block, so the author just has to select the form he wants to include...
Comment #5
quicksketchAnother interesting solution I've run across is having a hidden field on the first page of your form that contains
%get[q]as the default value. Then you can set your redirect toreturn $form_values['submitted_tree']['hidden_field_name']. Either way, I think we're good to close this issue.Comment #6
volocuga commentedwansinn:
Thank you, good working solution
The java you wrote has a small typo. It shoul be:
Comment #7
volocuga commentedUps, not so good. Confirmation message not showing
Comment #8
Aibu commentedUse the Ajax module for webform with the disable redirect plugin!