Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
aron.beal CreditAttribution: aron.beal commentedComment #3
DanChadwick CreditAttribution: DanChadwick commentedThe 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.