I'd like to build a webform that submits data to a 3rd party application. If the submission to that 3rd party application fails, how can I also "cancel" the submission itself?

I've looked into adding a form #validate callback, but the problem is it doesn't work for a multi-page form, as the callback only gets to see the values from the current page, not the whole submission.

I've also looked into the form insert and presave hooks, which can look at the complete submission, but the problem with those it that they can't "cancel" the submission itself in case the hook encounters a problem.

Thanks.

Comments

quicksketch’s picture

but the problem is it doesn't work for a multi-page form, as the callback only gets to see the values from the current page, not the whole submission.

The $form_state['values'] contains the current page, but $form_state['storage'] contains the entirety of the submission. You can use that in your own validation callback.

quicksketch’s picture

Status: Active » Closed (fixed)
lavamind’s picture

Oops, sorry for not responding.

For the record, I solved this problem using your suggestion : $form_state['values']

Thanks!