I have a webform inside a block on a page (let's say /actual-page).

When I use Webform Validation to validate any of my fields (using standard validation options such as Numeric), it redirects to the Webform node's page (let's say /my-form), rather than /actual-page.

I have tried created a redirect from "my-form" to "actual-page", and the redirects *does* work if you access /my-form directly, but it does not work when there's a validation error. The Webform Validation stops the Redirect module from working in this case. Obviously it would be even better if no redirect were needed.

I am curious if others have encountered this, or can reproduce this bug.

Comments

caspervoogt’s picture

Just to make sure, I tested this on a clean Drupal installation (using simplytest.me) with Webform and Webform Validation (7.x-1.5 rc1 .... no dev version available on simplytest.me). I was able to replicate this quite easily by making a form, setting the advanced settings to show it in a block, then assigning the block to be visible. I also added a basic validation rule (numeric). When a validation error is detected, it redirects to the webform node, rather than the page that the webform block was embedded on.

Liam Morland’s picture

Thanks for the report. Does this also happen during the failure of a validation rule that is built into Webform, instead of added by Webform Validation?

caspervoogt’s picture

I just tested with just Webform, using a basic "Unique" validation that comes with webform ... and it redirects to the correct page ... the page I had assigned the webform block to. Seems that Webform Validation's Ajax validation is pointing to the node/nid of the webform rather than the originating path. I had a look around the module code and couldn't spot what was doing the redirect, though. Someone more familiar with the module might have better luck identifying the relevant code block.

Liam Morland’s picture

There is no Ajax in Webform Validation. Are you sure this isn't being caused by the Clientside Validation module?

Liam Morland’s picture

I am not seeing a problem when Webform Validation fails, however, when submitting a form that is in a block, the "Go back to the form" link on the confirmation page goes to the form, not the original page containing the block. This happens even when Webform Validation is disabled, so that would be a Webform bug.

Reported in #2034989: Link "Back to previous page" links to wrong page when using webform as a block.

caspervoogt’s picture

"There is no Ajax in Webform Validation. Are you sure this isn't being caused by the Clientside Validation module?"
I ran tests using simplytest.me, once with Webform + Webform Validation, and then again with just Webform. I've actually never used https://drupal.org/project/clientside_validation. When I said "Seems that Webform Validation's Ajax validation is pointing to .." I was just speculating.

"I am not seeing a problem when Webform Validation fails"

I can't test the Webform Validation dev version on simplytest.me so maybe that's not the greatest bellwhether, but it's acting just as it did on my production site running the dev version. I just ran through it again though, and the basic Webform-only validation doesn't redirect to the webform's node... it stays on whatever page the form was embedded on. When I try to use Webform Validation though, it redirects to the form's node.

I did a video documenting this. I hope it helps. Bear with me as I think I repeat myself a bit ... it's late and I'm tired ;)

Here's my video; http://youtu.be/fh6DRJuwtrM

I hope I am not imagining things and that you can reproduce this on your end ;)

Liam Morland’s picture

7.x-1.5-rc1 is the same as 7.x-1.x at the moment. You can check that kind of thing by doing a git checkout and git diff of the branch vs. the tag.

Can you give steps for reproducing this on a new Drupal install?

caspervoogt’s picture

I run through the steps in the video (http://youtu.be/fh6DRJuwtrM), but here you go:

1. install Drupal
2. install Webform and Webform Validation
3. create a new node called "Home" or whatever alias you want .. this is so you can assign the block to this specific page. Your test page should be node/1
4. create a form. Add some fields to it. Make one field a text field, save, then go to Validation and add a validation rule that checks something about that field, for example that it must be numeric. The form is node/2.
5. edit form's advanced settings to make it available as a block.
6. go to block manager and assign the form block to node/1.
7. go to /node/1 and try entering a non-numeric value for the text field that was set to require numeric values. In my testing, this redirects to /node/2 rather than staying on /node/1. the page with the block.

Liam Morland’s picture

I tried your steps on my development box and I did not see the problem. I am using the latest development version of Webform. Have you reproduced it on a Drupal install outside of simplytest.me?

Liam Morland’s picture

Your problem sounds similar to #1953060: Webform block redirect on error (D7).

caspervoogt’s picture

You're absolutely right, Liam. "Your problem sounds similar to #1953060: Webform block redirect on error (D7)." That was it.
Seems like an odd default behavior to me, but I guess this one's a feature rather than a bug. I would think that form validation is to be expected, and when a form is in a block the subsequent error messages should happen on whatever path the form was on. So this is a Webform issue, rather than a Webform Validation issue.

That solved it for me.

caspervoogt’s picture

Status: Active » Closed (works as designed)