You are here

form--group.html.twig in Open Social 8.8

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.
  • 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

themes/socialbase/templates/form/form--group.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 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 themeable
  23. */
  24. #}
  25. {%
  26. set classes = [
  27. 'form-group',
  28. ]
  29. %}
  30. <fieldset{{ attributes.addClass(classes) }}>
  31. {%
  32. set label_classes = [
  33. 'control-label',
  34. required ? 'js-form-required',
  35. required ? 'form-required',
  36. ]
  37. %}
  38. {# Always wrap fieldset legends in a SPAN for CSS positioning. #}
  39. <label{{ legend.attributes.addClass(label_classes) }}>
  40. <span{{ legend_span.attributes }}>{{ legend.title }}</span>
  41. </label>
  42. <div class="fieldset-wrapper">
  43. {% if errors %}
  44. <div>
  45. {{ errors }}
  46. </div>
  47. {% endif %}
  48. {% if prefix %}
  49. <span class="field-prefix">{{ prefix }}</span>
  50. {% endif %}
  51. {{ children }}
  52. {% if suffix %}
  53. <span class="field-suffix">{{ suffix }}</span>
  54. {% endif %}
  55. {% if description.content %}
  56. <div{{ description.attributes.addClass('help-block') }}>{{ description.content }}</div>
  57. {% endif %}
  58. </div>
  59. </fieldset>