0

I need to transfer the submission ID to the client side after a webform is submitted. The problem is that after submission the Confirmation page is showed. And how can I attach the current sid to a page? I know how to do it on a node (se below) with Drupal behaviors on a client side JS-script.

Anyone? Or maybe the sid can be transfered to the client side another way?

function mymodule_webform_submission_insert($node, $submission) {
 // $node will give you the node id of your webform
 // $submission will give you the id of your data which you inserted in web form
 $sid = $submission->sid ? $submission->sid : FALSE;
 if($sid){
   $currentSid = array('mymodule' => array('sid' => $sid));
   $node->content['#attached']['js'][] = array(
     'data' => $currentSid,
     'type' => 'setting',
   );
 }
}

1 Answer 1

1

You could start by putting the submission id into $_SESSION and add it to Drupal's js settings

drupal_add_js(array('mymodule' => array('webform_id' => $_SESSION['webform_id'])), 'setting');

Then access it on the client side

webform_id = Drupal.settings.mymodule.webform_id
2
  • Thanks for your answer. Please bare with me, I can't get it to work. Where do I add the actual value of the submission ID in the key webform_id?
    – TBJ
    Commented Apr 5, 2017 at 7:21
  • Disregard the comment above. I am an idiot... Thanks again for the solution!
    – TBJ
    Commented Apr 5, 2017 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.