How to access webform elements in webform.html.twig

Created on 1 April 2017, over 7 years ago
Updated 7 February 2023, almost 2 years ago

Hi,
I'm trying to figure out a way to access webform elements from webform.html.twig.
I need to style the form; wrapping some elements and adding bunch of styles
all I have in the webform.html.twig is "children" variable which renders the whole form, whereas I need to access every element individually.

I found a link on the web for webform-form.html.twig which might do what I need, however I can't find it in webform template folder
http://cgit.drupalcode.org/webform/tree/templates/webform-form.html.twig?id=1135b65031cd6cd195c2e638300e5ef945a6f652

Any help with this matter is much appreciated.

💬 Support request
Status

Fixed

Version

5.0

Component

Miscellaneous

Created by

🇪🇬Egypt isamir

Live updates comments and jobs are added and updated live.
  • theming

    Used in Documentation issues related to theming

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India raghwendra

    For me #13 solution is working but not coming default actions / submit button of form. I tried the followings:
    {{ element.actions }}
    {{ element.elements.actions }}
    {{ form.elements.actions}}
    I also used the captcha.
    Can you please share the solutions?

  • 🇧🇭Bahrain drattar

    in my case, to render webform element title, and the element itself:

                    {{ form.elements.name['#title'] }}
                    {{ form.elements.name|without('#title') }}
Production build 0.71.5 2024