Hi,

webform_submission_insert has the following loop to implement the webform api:

    foreach (module_implements('webform_submission_presave') as $module) {
      $function = $module . '_webform_submission_presave';
      $function($node, $submission);
    }

The problem is, subsequent to the loop there are no checks made to ensure the submission is still valid. What I'm angling for here is a way to allow the presave hook to invalidate the save operation by removing the entry such that
empty($submission) === TRUE

(or some similar condition that achieves the same effect. Is this possible? Do you have a preferred approach?

Comments

aron.beal created an issue. See original summary.

aron.beal’s picture

Issue summary: View changes
DanChadwick’s picture

Status: Active » Closed (works as designed)

The submission has already been validated at this point. I would suggest that you use hook_webform_client_form_alter() to add whatever validation handler you need to prevent the submission.

Or you might consider letting the submission get saved, but delete it afterwards. You could look at the webform_clear module for ideas about this.

I don't see this as something that needs to be added the the API, at least not without more demand and an extensive analysis of why other techniques aren't sufficient. Please feel free to re-open with that if desired. Good luck.