Closed (fixed)
Project:
Webform
Version:
7.x-4.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Oct 2014 at 13:17 UTC
Updated:
15 Oct 2014 at 13:54 UTC
Jump to comment: Most recent
Hello,
I have recently updated Webform from 7.x-4.0-alpha9 to the latest stable 7.x-4.0.
I have built a very large, multipage webform on our website with a hook_webform_submission_presave at the end to perform a couple of actions before saving the submission. As you know, this hook has two parameters, $node and $submission. Before the update, everything was fine. After the update, I noticed that $submission contains every variable as before, except the submission ID (SID).
I really need that variable at that point in the script. Is there something I have to do first in order to get the SID in hook_webform_submission_presave?
Thanks in advance.
Comments
Comment #1
danchadwick commentedMmmmm, I don't see this looking at the code.
Presave is invoked before an existing submission is updated. In this case the sid will be set.
Presave is invoked before a new submission is inserted. In this case the sid will not exist yet.
You might prefer hook_webform_submission_update or hook_webform_submission_insert. In both of these, the sid will have already been set. Not that only one or the other is called, whereas presave is called in both situations.
This is akin to elsewhere in Drupal where presave + (update or insert) hooks are used.
I can't say with absolute certainty that this behavior is the same as in alpha9 (because I didn't bother to look), but I can say that it is the correct intended behavior.
NOW, if you find that what I said isn't correct, then please change back to a bug report and re-open.