file fieldset.html.twig

Theme override to display 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.
  • 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.

File

templates/form/fieldset.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override to display 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 of the legend.
  12. * - attributes: HTML attributes to apply to the legend.
  13. * - description: The description element containing the following properties:
  14. * - content: The description content of the fieldset.
  15. * - attributes: HTML attributes to apply to the description container.
  16. * - children: The rendered child elements of the fieldset.
  17. * - prefix: The content to add before the fieldset children.
  18. * - suffix: The content to add after the fieldset children.
  19. *
  20. * @see template_preprocess_fieldset()
  21. *
  22. * @ingroup uikit_themeable
  23. */
  24. #}
  25. {%
  26. set classes = [
  27. 'js-form-item',
  28. 'form-item',
  29. 'js-form-wrapper',
  30. 'form-wrapper',
  31. 'uk-fieldset',
  32. ]
  33. %}
  34. {%
  35. set description_classes = [
  36. 'description',
  37. 'uk-text-meta',
  38. 'uk-margin-small-top',
  39. ]
  40. %}
  41. <fieldset{{ attributes.addClass(classes) }}>
  42. {%
  43. set legend_span_classes = [
  44. 'fieldset-legend',
  45. required ? 'js-form-required',
  46. required ? 'form-required',
  47. ]
  48. %}
  49. {# Always wrap fieldset legends in a <span> for CSS positioning. #}
  50. <legend{{ legend.attributes.addClass('uk-legend') }}>
  51. <span{{ legend_span.attributes.addClass(legend_span_classes) }}>{{ legend.title }}</span>
  52. </legend>
  53. <div class="fieldset-wrapper">
  54. {% if errors %}
  55. <div>
  56. {{ errors }}
  57. </div>
  58. {% endif %}
  59. {% if prefix %}
  60. <span class="field-prefix">{{ prefix }}</span>
  61. {% endif %}
  62. {{ children }}
  63. {% if suffix %}
  64. <span class="field-suffix">{{ suffix }}</span>
  65. {% endif %}
  66. {% if description.content %}
  67. <div{{ description.attributes.addClass(description_classes) }}>{{ description.content }}</div>
  68. {% endif %}
  69. </div>
  70. </fieldset>

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Log in