fieldset.html.twig

Same filename in this branch
  1. 8.9.x core/profiles/demo_umami/themes/umami/templates/classy/form/fieldset.html.twig
  2. 8.9.x core/themes/seven/templates/classy/form/fieldset.html.twig
  3. 8.9.x core/themes/claro/templates/fieldset.html.twig
  4. 8.9.x core/themes/bartik/templates/classy/form/fieldset.html.twig
  5. 8.9.x core/themes/classy/templates/form/fieldset.html.twig
  6. 8.9.x core/modules/system/templates/fieldset.html.twig
Same filename in other branches
  1. 9 core/profiles/demo_umami/themes/umami/templates/classy/form/fieldset.html.twig
  2. 9 core/themes/olivero/templates/form/fieldset.html.twig
  3. 9 core/themes/stable9/templates/form/fieldset.html.twig
  4. 9 core/themes/seven/templates/classy/form/fieldset.html.twig
  5. 9 core/themes/claro/templates/fieldset.html.twig
  6. 9 core/themes/bartik/templates/classy/form/fieldset.html.twig
  7. 9 core/themes/stable/templates/form/fieldset.html.twig
  8. 9 core/themes/starterkit_theme/templates/form/fieldset.html.twig
  9. 9 core/themes/classy/templates/form/fieldset.html.twig
  10. 9 core/modules/system/templates/fieldset.html.twig
  11. 10 core/profiles/demo_umami/themes/umami/templates/classy/form/fieldset.html.twig
  12. 10 core/themes/olivero/templates/form/fieldset.html.twig
  13. 10 core/themes/stable9/templates/form/fieldset.html.twig
  14. 10 core/themes/claro/templates/fieldset.html.twig
  15. 10 core/themes/starterkit_theme/templates/form/fieldset.html.twig
  16. 10 core/modules/system/templates/fieldset.html.twig
  17. 11.x core/profiles/demo_umami/themes/umami/templates/classy/form/fieldset.html.twig
  18. 11.x core/themes/olivero/templates/form/fieldset.html.twig
  19. 11.x core/themes/stable9/templates/form/fieldset.html.twig
  20. 11.x core/themes/claro/templates/fieldset.html.twig
  21. 11.x core/themes/starterkit_theme/templates/form/fieldset.html.twig
  22. 11.x core/modules/system/templates/fieldset.html.twig

Theme override for a fieldset element and its children.

Available variables:

  • attributes: HTML attributes for the <fieldset> element.
  • errors: (optional) Any errors for this <fieldset> element, may not be set.
  • required: Boolean indicating whether the <fieldeset> element is required.
  • legend: The <legend> element containing the following properties:
    • title: Title of the <fieldset>, intended for use as the text of the <legend>.
    • attributes: HTML attributes to apply to the <legend> element.
  • description: The description element containing the following properties:
    • content: The description content of the <fieldset>.
    • attributes: HTML attributes to apply to the description container.
  • children: The rendered child elements of the <fieldset>.
  • prefix: The content to add before the <fieldset> children.
  • suffix: The content to add after the <fieldset> children.

See also

template_preprocess_fieldset()

File

core/themes/stable/templates/form/fieldset.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override for a fieldset element and its children.
  5. *
  6. * Available variables:
  7. * - attributes: HTML attributes for the <fieldset> element.
  8. * - errors: (optional) Any errors for this <fieldset> element, may not be set.
  9. * - required: Boolean indicating whether the <fieldeset> element is required.
  10. * - legend: The <legend> element containing the following properties:
  11. * - title: Title of the <fieldset>, intended for use as the text
  12. of the <legend>.
  13. * - attributes: HTML attributes to apply to the <legend> element.
  14. * - description: The description element containing the following properties:
  15. * - content: The description content of the <fieldset>.
  16. * - attributes: HTML attributes to apply to the description container.
  17. * - children: The rendered child elements of the <fieldset>.
  18. * - prefix: The content to add before the <fieldset> children.
  19. * - suffix: The content to add after the <fieldset> children.
  20. *
  21. * @see template_preprocess_fieldset()
  22. */
  23. #}
  24. {%
  25. set classes = [
  26. 'js-form-item',
  27. 'form-item',
  28. 'js-form-wrapper',
  29. 'form-wrapper',
  30. ]
  31. %}
  32. <fieldset{{ attributes.addClass(classes) }}>
  33. {%
  34. set legend_span_classes = [
  35. 'fieldset-legend',
  36. required ? 'js-form-required',
  37. required ? 'form-required',
  38. ]
  39. %}
  40. {# Always wrap fieldset legends in a <span> for CSS positioning. #}
  41. <legend{{ legend.attributes }}>
  42. <span{{ legend_span.attributes.addClass(legend_span_classes) }}>{{ legend.title }}</span>
  43. </legend>
  44. <div class="fieldset-wrapper">
  45. {% if errors %}
  46. <div>
  47. {{ errors }}
  48. </div>
  49. {% endif %}
  50. {% if prefix %}
  51. <span class="field-prefix">{{ prefix }}</span>
  52. {% endif %}
  53. {{ children }}
  54. {% if suffix %}
  55. <span class="field-suffix">{{ suffix }}</span>
  56. {% endif %}
  57. {% if description.content %}
  58. <div{{ description.attributes.addClass('description') }}>{{ description.content }}</div>
  59. {% endif %}
  60. </div>
  61. </fieldset>

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.