Answer the question
In order to leave comments, you need to log in
How to place a contact form (webform) in the body of the page?
Hello! Please tell me, otherwise I don’t understand (inexperienced)
I created a feedback form, and I want to place it in the body of a page or article. How can I do that?
The text is in CKEditor, maybe there is some shortcode that will work?
Drupal 8
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
// THEMENAME.theme
function THEMENAME_preprocess_node__NODE_ID(array &$vars) {
$webform_build = [
'#type' => 'webform',
'#webform' => 'WEBFORM_ID',
];
$vars['content']['body'][0]['#text'] = str_replace('[webform]', render($webform_build), $vars['content']['body'][0]['#text']);
}
Webform can be rendered as a block. From here, there are many options for how to withdraw:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question