I have the following setup

  • Drupal 6.x
  • Webform 6.x - 3.17
  • reCAPTCHA 6.x - 1.17

I also have the following custom module

function webform_to_data_repo_form_alter(&$form, &$form_state, $form_id) 
if ($form_id == 'webform_client_form_765') 
        $form['#action'] = url('some-external-site.com', array('external' => true));
        $form['#method'] = 'post';

As it is now, the form is able to communicate with the external website. It cannot however validate entered values before it submits.

This lack of validation is a problem for several reasons because

  1. The CAPTCHA field can be left blank, which defeats its purpose.
  2. Any field that I specifically made mandatory can now be left blank, again defeating its purpose.

I've also read on multiple occasions that once you use $form['#action'], any attempts on validation will cease to work.

I was wondering if there was a way I could prioritize the validation of forms over $form['#action'] and if so, how?

If you could just point me to the right direction, in terms of what my custom module is missing, I'd appreciate it.

Thanks in advance.


If you want to validate form, you need to leave action intact. Then, you can send it's content to external server in it's save handler using it's api or drupal_http_request().

The point is - action tells the browser where to send the data. If you make it send data to external server, your Drupal will never get it, so it will have no opportunity to interact with it. Of course you might try to implement validation in browser too, using JavaScript, but that's unreliable and shouldn't be used as an only way of validation.

  • Thank you very much. I was able to utilize drupal_http_request() through hook_form_submit. On a relative note, is it possible to redirect user to the webform's default Submission Successful page?
    – johnmiste
    May 31 '13 at 15:54
  • You can redirect him wherever you want using drupal_goto()
    – Mołot
    Jun 3 '13 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.