0

I have created a custom module for a custom Webform handler. The custom handler submits to an external SOAP api. There are various response options that are received back from the SOAP api that currently I am printing to screen (for testing purposes). But when using this module in production, I obviously want these responses to be displayed at the top of the confirmation page.

Is there some way to populate a token (possibly the Webform Handler Response token?), which I can then use to print the information on my confirmation page?

F

0

Your two options are…

OPTION 1: Add the SOAP API's response value as a hidden element's value using something like

$webform_submission->setElementData('response_value', $response->value);
$webform_submission->resave();

OPTION 1: Store the response in $_SESSION and use

\Drupal\webform\Plugin\WebformHandlerInterface::confirmForm
\Drupal\webform\Plugin\WebformHandlerInterface::preprocessConfirmation

to alter the confirmation message or page.

  • Thanks jrockowitz. I've tried Option 1 but I am getting a Duplicate entry error. I think it's because I am trying that within the preSave function. Do I need to alter the code to use with preSave? – FrankDesign Aug 1 at 17:21
  • Don't call $webform_submission->resave(); if you are setting the element data via ::preSave() – jrockowitz Aug 2 at 9:25

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.