protected function WebformSubmissionDuplicateForm::setConfirmation in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionDuplicateForm.php \Drupal\webform\WebformSubmissionDuplicateForm::setConfirmation()
Set webform state confirmation redirect and message.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides WebformSubmissionForm::setConfirmation
File
- src/
WebformSubmissionDuplicateForm.php, line 27
Class
- WebformSubmissionDuplicateForm
- Provides a webform to duplicate existing submissions.
Namespace
Drupal\webformCode
protected function setConfirmation(FormStateInterface $form_state) {
parent::setConfirmation($form_state);
// If the form is just reloading the duplicate form, redirect to the
// new submission.
$redirect = $form_state
->getRedirect();
$route_name = $this
->getRouteMatch()
->getRouteName();
if ($redirect instanceof Url && $redirect
->getRouteName() === $route_name) {
/** @var \Drupal\webform\WebformSubmissionInterface $entity */
$webform_submission = $this->entity;
$source_entity = $webform_submission
->getSourceEntity();
$redirect_url = $this->requestHandler
->getUrl($webform_submission, $source_entity, 'webform_submission.canonical');
$form_state
->setRedirectUrl($redirect_url);
}
}