In my webforms, I would like to (visually) group certain elements for my visitors:
I've successfully managed to build this using container elements (sections) in the Drupal webform backend ui.
However, I notice that wehn I move webform elements into one of my container elements, some of my custom code no longer works. These elements are now sub-elements and end up somewhere else in the $form
array. For example, code that targets the 'name' field simply no longer works after I add it to the 'personal' section.
Is there any way to group elements strictly visually (i.e. without any consequences for the array and my custom code)?
P.S.
The only possibility I can think of is to create a twig template (webform--MYFORM.html.twig) where I render every element separately so I can group them with custom HTML, but that practically renders the webform ui builder useless, as I have to make all my changes in code and manually add any new element. Furthermore, it seems very error prone as leaving out a (hidden) element by mistake will cause problems with form submissions.
Active
6.2
User interface