1

I have created a form using webform module, and alter form In D7

function mymodule_form_alter(&$form, &$form_state, $form_id) {

  global $user;

  if('webform_client_form_1' == $form_id) {

    $form['#validate'][] = 'mymodule_check_email';   

  }

}

function mymodule_check_email($form, &$form_state, $form_id) {

.............

.............

}

I write print_r($form_state); in mymodule_check_email function.

Get all variables but sid value is empty but in database sid insert proper.

My question how to get sid value.

2
  • Which version of webform are you using ??
    – Rupesh
    Commented Jun 16, 2016 at 10:41
  • webform 7.x-3.19 Commented Jun 16, 2016 at 10:42

1 Answer 1

1

The sid won't be available from a validation handler; validation handlers are called before form submission, thus a valid sid for your submission doesn't exist at time of execution.

If you need to call a post-submit webform hander, the webform module provides hook_webform_submission_insert():

function mymodule_webform_submission_insert($node, $submission) {
  // The submission object contains $submission->sid, the submission id.
  print_r($submission);
}
1
  • yes, this is right answer vote up.
    – Yuseferi
    Commented Jul 26, 2016 at 9:40

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.