The webform module is being used for a form that takes a payment. The data is validated as much as it can and then in a submit handler it is finally sent to the payment processor.
The result can be a failure (wrong card number, or no funds etc.), which should result in the form being re-presented giving the user the opportunity to check their fat fingers didn't type in the wrong card details, try another card etc.
In a vanilla Drupal form I could do a $form_state['redirect'] = FALSE;
and it would return the form as-is, but this does not work when working within webform because it deals with that itself.
So this is a weird one because it's basically validation done in a submit handler. This is because we need to make sure everything's valid before submitting it to the third party, but there are clearly two ways to frame this question:
As the title says, is it possible for a submit handler to tell webform to stay on this page and not consider it complete?
or
If I move the submission code into a validation handler, how can I ensure my validation handler happens after all the others, and then check that there aren't any other validation errors before I proceed with the payment submission?
form_set_error()
after adpm($form_state)
to debug your values. Theform_set_error()
simply stops the process, so the submit won't get fired.