If you override the $form_state['redirect'] using hook_form_alter and put in your own URL you will not receive any $_POST variables. Why? Apparently there used to be a function for this but it was stripped out. There is also a helper app for it which I installed which, when enabled, doesn't fix the problem.

Is there a solution or a work around for this?

Comments

quicksketch’s picture

Category: Feature request » Support request

This is a coding question, which specifically isn't covered in the support provided in the Webform issue queue. But this question isn't actually even related to Webform's behavior, it's Drupal's FormAPI that emptys out $_POST (to help with security). Instead of using $_POST, use the $form_state argument that comes into your submit handler. The contents of $_POST (after sanitation) are in $form_state['values']. That might not be the only problem with your code, considering it sounds like you may be trying to affect the redirect in hook_form_alter() itself, when what you may need is to add a submit handler in the alter and then put your redirect code in the submit handler. Perhaps the documentation page for custom validation/submit handling could help you.

agalligani’s picture

Thanks. I normally I use the Form API. I was using Webform because I was instructed to do so in order for the client to be able to change the label of the input fields. The problem I had was that I didn't need Webforms normal functionality... ie creating and storing the fields in a form. I needed to post to a custom script.

Eventually I was able to get $_POST to work after all. I reset the form action to point to the page I needed with jquery and eventually got $_POST to work. There are some hidden fields at the bottom of the form... I think I might have disabled them, and that might have been what worked..... Anyhow the form now routes around the webform submit handlers and $_POST yields results on the destination page.

Perhaps not related to webform's behavior, but it used to be an feature that was removed. I'm thinking someone else must also have found it useful. I find that a lot of Drupal novices look to webform to do things that it probably wasn't intended for - many of them either don't understand the Form API but maybe know enough PHP that they want to create a form with webform and not use it to create a node, but to do something else. Having a $_POST variable option might be a good thing.

danchadwick’s picture

Status: Active » Closed (works as designed)