Score:0

Is there a way to set a
wrapper around a webform without customizing the webform?

bj flag
hao

I would like to add a <div> wrapper around a webform. Is there a way to define the wrapper without customizing the webform?

Score:3
us flag

You do this via the YAML source

'#prefix': '<div class="custom-wrapper">'
'#suffix': '</div>'
textfield:
  '#type': textfield
  '#title': textfield

I did find a bug that I created a ticket for in the Webform issue queue and posted a patch. I recommend using the above approach with the patch.

Score:0
cn flag

It's a bit difficult to tell what you mean by "without customizing the webform", but if you mean "without editing the webform configuration of each webform," then you can theme webforms like any other entity in Drupal.

If you check the webform/templates directory, you will see the file webform.html.twig. You can copy this file into your site's theme templates directory and add the <div> wrapper in this file.

After you rebuild the site's cache, all webforms will now have the <div> wrapper that you added to webform.html.twig.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.