I am working with a feature where a newsletter subscription form (Webform with ajax submission and confirmation type is inline) should appear in a node. The node would be showing as a popup and the contents of popup is being loaded using ajax. When the node is tested in it's own node page the submission is working fine but not in the popup.It is redirecting to another page. Inspecting the two cases, i found that the webform while being loaded in popup, lacks event
handler that should refer to form submission.
In the controller where webform being loaded into the popup block, something like this is tried:
$webform = $this->entityTypeManager->getStorage('webform')->load($formId);
$view_builder = $this->entityTypeManager->getViewBuilder('webform');
$build = $view_builder->view($webform);
Where $formId
is the id of the webform and entityTypeManager is an instance of Drupal\Core\Entity\EntityTypeManagerInterface
.
Later this $build
is being saved as the webform
attribute of popup class and later being rendered. The fields of the webform appears to be loaded correctly but not the event
of submission form.
Any suggestion for solving the issue?