I recently update from Webform 7.x-3.11 to 7.x-3.13 and had an problem come up. I had a form that was in a block and had no redirect selected as the Redirect location. In 7.x-3.11 it worked as expected and redirected to the page it was submitted from, but after updating to 7.x-3.13 it no longer redirects to the node where it is submitted from but to the form its self.

Just to make sure i did a clean install of drupal 7.9x and webfrom 7.x-3.13 created a form with a text field selected the "No redirect" Option, checked the "Available as block" option, created a new node (node/2) and attached the block to this page.

When I submit the form from node/2 (Basic Page) it redirects to the webform after submission.

Thanks.

CommentFileSizeAuthor
#7 no-redirect_1337784_8.patch629 bytessteffenr

Comments

halloffame’s picture

I have the exact same problem but with 6.x-3.14.

quicksketch’s picture

A similar request but filed under support is over here #1337784: Selecting "No redirect" does not reload current page.. They're both likely the same problem.

halloffame’s picture

@quicksketch your link points right back to this thread.

LeLe87’s picture

Same configuration, same problem.

quicksketch’s picture

nuez’s picture

I´ve solved this by simply overriding the '#action' in the form...its a hack, but it might inspire the maintainers to fix the bug...

function mymodule_form_alter (&$form, &$form_state, $form_id){
  if(isset($form['#node']) && $form['#node']->type == "webform"){
    $form['#action'] = url(drupal_get_path_alias($_GET["q"]));
  }
}
steffenr’s picture

Status: Active » Needs review
StatusFileSize
new629 bytes

I tried to reproduce the issue and finally found a working solution - it's just a NOT before the empty($block_settings['pages_block']) call. Please check if the patch works for you too..

erichomanchuk’s picture

The patch posted by SteffenR is working for me.

Thank you.

BreadAndPixels’s picture

#7 (SteffenR): Good patch!

quicksketch’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hi guys, thanks for the patch @SteffenR and the reviews from everyone. Unfortunately I can't make sense of this problem. In my testing, everything works exactly as it should. From the code, it also all looks correct. Adding a NOT ('!') in front of empty($block_settings['pages_block']) doesn't make sense, because that variable is basically saying "Should the pages be in the block?" by putting NOT in front of it, the statement now says, "If the pages should be in the block, then don't put them in the block (put them in the node instead)". This doesn't make any sense.

So the only thing I can think may be causing the problem is that the setting isn't getting saved properly. Could someone who is having the problem try this out?

- Create a new webform node, make a simple form in it, then expose it as a block.
- Edit the block configuration, check the box for "Show all webform pages in block".
- Edit the block configuration *again*, and make sure that box is still checked.

It would also be helpful to know what URL you are editing the block from. On my local, it's:

admin/structure/block/manage/webform/client-block-33/configure

Where "33" is the Node ID. With this information I might be able to deduce where this problem is coming from, but right now I'm failing to reproduce it.

malberts’s picture

I had the same problem, but #10 works for me.

Admittedly, I did not read the readme or any other file since I've used webform 6 before, so I don't know if #10 is mentioned in there.

If you edit the block using Structure/Blocks/ThemeName... then you don't get that checkbox (admin/structure/block/manage/block/6/configure). If you edit the block using the cog on the page itself then you get to the path in #10 with that checkbox (admin/structure/block/manage/webform/client-block-1/configure).

dddbbb’s picture

I keep getting tripped up by this.

Yes, #10 works for me too.

ColonelForbinX’s picture

Dynamically setting the redirect URL of a webform block using $form_state['redirect'] was not working for me after upgrading from 3.x-11 to 3.x-13.

Was tearing my hair out, but I can now confirm that the "Show all webform pages in block" mentioned in #10 was the missing piece. Thanks a lot.

quicksketch’s picture

@ColonelForbinX: So you're saying that the stock Webform install works correctly, right? I still haven't been able to reproduce a problem at all. I'm worried from the posts in this issue that people have modified their Webform module code, so I can't really trust a lot of the posts I've seen so far.

jonnyMo’s picture

Version: 7.x-3.13 » 6.x-3.15

quicksketch: I've been having this same problem in 6x-3.15, and have not made any patches to the Webform code. Checking "show all webform pages in block" fixes the problem for me as well. This is still a bug, tho. At least in the UI sense: If you have a 1-page webform (as I do) available as a block, you should not have to click "show all webform pages in block" in order for the webform to redirect back to the current page correctly. That said, it's a relief that there's an easy fix, even if it's a bit counterintuitive. Hope that helps!

quicksketch’s picture

This is still a bug, tho. At least in the UI sense: If you have a 1-page webform (as I do) available as a block, you should not have to click "show all webform pages in block" in order for the webform to redirect back to the current page correctly.

Up until this feature was added, that was the only behavior and it was intentional under the assumption that if you were starting a form you'd enter minimal information (such as an e-mail address) to start the form, then you'd want the rest of the form on a larger page. At this point we can't make it the default behavior without affecting thousands of existing sites.

erichomanchuk’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

#10 does indeed work, but the checkbox "Show all webform pages in block" did not exist on the block configuration page for webform 7.x-3.11 the webform in the block worked as expected by select "show in block" and "no redirect".

I did follow your steps outlined and the form does behave correctly.

The issue was from upgrading from 7.x-3.11 to 7.x-3.13 where the webform stoped working because the option "Show all webform pages in block" wasn't necessary to get the form working as expected, but since the upgrade I needed to check this new option on my block (my webform was just a newsletter subscription with a email and name field and nothing else, not multistep).

Sooo no patch is needed just follow the steps outline by quicksketch on #10 and when upgrading remember to tic the new option available in your block.

Thanks quicksketch for clarifying.

ben.hamelin’s picture

Hello all, just happened upon this thread after upgrading from 3.11 > 3.15
I understand the issue, but have a question for the module maintainers.
At what point was the "Show all pages in webform block" setting added?
This block of code:

$pages_in_node = TRUE;
  if (isset($node->webform_block)) {
    $webform_blocks = variable_get('webform_blocks', array());
    $delta = 'client-block-' . $node->nid;
    $block_settings = isset($webform_blocks[$delta]) ? $webform_blocks[$delta] : array();
    $pages_in_node = empty($block_settings['pages_block']);
  }

differs from the 3.11 test, which simply tests to see if the webform has been assigned as a block.

Just wondering how many people have updated from 3.11 > 3.15, it's only been 12 days.
For me, this requires an adjustment to all webform blocks after this upgrade.

longtom’s picture

I had this, and even experienced different redirections whether the user was logged in or not.

...there was a painfully obvious setting in the block configuration, 'Show all webform pages in block' that does what I want.

tinarey’s picture

#10 works, thanks. I even noticed the field but didn't check it because I plainly didn't understand the description and couldn't connect it to my problem later... Maybe a foolproof "Check this if you're having trouble with..." would help?

joecanti’s picture

hi,

This is an edge case example I came across where it doesn't work so well:

I have the first page of my form in a block - when users complete and go to the second page, it goes to the page - this works great. But, if I use #10, the second page gets loaded in the first page block, which throws things out a bit.

It's nice to have the first half of your form in a small square on your homepage, and then upon completion go to the main form second page. It also has the bonus of being able to start the form in different locations.

So - I guess the ideal solution would be to have a redirect option in the webform advanced settings. EG:

Upon validation fail either 1. return to same page url or 2. go to this page: ...

Again, this is probably edge case and it's not going to have much of an impact on my site - really just a little on the stats.

Thanks, Joe

dagomar’s picture

Related issue on 7.x-4 with patch:
#2158261: Webform block redirects to page by default

dddbbb’s picture

blacklabel_tom’s picture

+1 for #10, maybe this should be made clearer when you expose a webform as a block in the settings?