Closed (outdated)
Project:
Webform
Version:
8.x-5.12
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 May 2020 at 01:13 UTC
Updated:
28 May 2020 at 01:54 UTC
Jump to comment: Most recent
I was trying to load webform after page load using AJAX and after the page load the submission is broken and on submit its taking to the AJAX controller URL. I saw a similar issue in `bigpipe` but i am not using `bigpipe`
STPES:
1) After page load called a AJAX function to load the block and place it in a DIV.
2) The controller has the following code to render the block
$build['webform'] = [
'#type' => 'webform',
'#webform' => $webform_id,
];
$rendered = \Drupal::service('renderer')->renderRoot($build);
return new JsonResponse($rendered);3) On submit the submission is taking to the AJAX controller path used to load the block and submission broken
Comments
Comment #2
jrockowitz commentedThis is an ajax and custom code issue. A form when rendered will automatically use the current URL's path. You probably need to alter the form's action attribute. You could also look into the '_wrapper_format' parameter. (ie /webform/contact?_wrapper_format=drupal_modal)