1

How can I load a webform submission programmatically ?

I've tried : $webform_submission = WebformSubmission::load($sid);

but it return null.

I do this in a custom module call by an handler after webform submission.

  • What is the content of the variable $sid? – 4k4 Jun 7 '18 at 11:25
  • It's a submission ID – Leeroy521 Jun 7 '18 at 11:32
  • I meant the actual content, this would be the first step to debug this. – 4k4 Jun 7 '18 at 11:34
  • I'm getting the submission ID from a custom handler, the data is send by GET to my controller (ID is 1051 currently) – Leeroy521 Jun 7 '18 at 12:44
  • Did you check if the sid 1051 exists in admin/structure/webform/submissions/manage? – 4k4 Jun 7 '18 at 13:05
4

I think you have to load sid like below

// Load submission using sid.
/** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
$webform_submission = \Drupal\webform\Entity\WebformSubmission::load($sid);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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