You are here

fieldset.html.twig in Open Social 8.8

Default theme implementation 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/fieldset.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation 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 ? 'form-group',
  28. not form_group ? 'js-form-wrapper',
  29. not form_group ? 'form-wrapper',
  30. ]
  31. %}
  32. <fieldset{{ attributes.addClass(classes) }}>
  33. {%
  34. set label_classes = [
  35. form_group ? 'control-label',
  36. required ? 'js-form-required',
  37. required ? 'form-required',
  38. title_display == 'invisible' ? 'sr-only',
  39. ]
  40. %}
  41. {# Always wrap fieldset legends in a SPAN for CSS positioning. #}
  42. <label{{ legend.attributes.addClass(label_classes) }}>
  43. <span{{ legend_span.attributes }}>{{ legend.title }}</span>
  44. </label>
  45. {%- if required -%}
  46. <span class="form-required">*</span>
  47. {%- endif -%}
  48. {% if description.content %}
  49. <div{{ description.attributes.addClass('help-block') }}>{{ description.content }}</div>
  50. {% endif %}
  51. <div class="fieldset-wrapper">
  52. {% if prefix %}
  53. <span class="field-prefix">{{ prefix }}</span>
  54. {% endif %}
  55. {{ children }}
  56. {% if suffix %}
  57. <span class="field-suffix">{{ suffix }}</span>
  58. {% endif %}
  59. </div>
  60. {% if errors %}
  61. <div class="form-item--error-message alert alert-danger alert-sm alert-dismissible form-control-radius">
  62. <a href="#" role="button" class="close" data-dismiss="alert" aria-label="{{ 'Close'|t }}"><span aria-hidden="true">&times;</span></a>
  63. {{ errors }}
  64. </div>
  65. {% endif %}
  66. {# {% if description_display !== 'before' and description.content %}#}
  67. {# <div{{ description.attributes.addClass('help-block') }}>{{ description.content }}</div>#}
  68. {# {% endif %}#}
  69. </fieldset>