0

I've made a webform with a handler. This handler does a Remote Post towards an API. This API is actually a custom module within the Drupal install which (after some logic) passes all of the preprocessed data towards another API. When that is passed successfully I get a redirect URL back from them, but whatever I use (TrustedRedirectResponse or just normal RedirectResponse) it won't redirect. It just reloads the form.

How to solve this?

0

I've added the following to the handler:

/**
* {@inheritdoc}
*/
public function confirmForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
  if ($this->isDisabled()) {
    return;
  }

  $uri = new Url('entity.node.webform.user.submission', [
    'node' => $webform_submission->getSourceEntity()->id(),
    'webform_submission' => $webform_submission->id(),
  ]);
  $form_state->setResponse(new RedirectResponse($uri->toString()));
}

This seems to work.

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.