You are here

fieldset--gin-lb.html.twig in Gin Layout Builder 1.0.x

Theme override for a fieldset element and its children.

File

templates/form/fieldset--gin-lb.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override for a fieldset element and its children.
  5. *
  6. * @see template_preprocess_fieldset()
  7. * @see claro_preprocess_fieldset()
  8. */
  9. #}
  10. {%
  11. set classes = [
  12. 'fieldset',
  13. attributes.hasClass('fieldgroup') ? 'fieldset--group',
  14. 'js-form-item',
  15. 'form-item',
  16. 'js-form-wrapper',
  17. 'form-wrapper',
  18. ]
  19. %}
  20. {%
  21. set wrapper_classes = [
  22. 'fieldset__wrapper',
  23. attributes.hasClass('fieldgroup') ? 'fieldset__wrapper--group',
  24. ]
  25. %}
  26. {%
  27. set legend_span_classes = [
  28. 'fieldset__label',
  29. attributes.hasClass('fieldgroup') ? 'fieldset__label--group',
  30. required ? 'js-form-required',
  31. required ? 'form-required',
  32. ]
  33. %}
  34. {%
  35. set legend_classes = [
  36. 'fieldset__legend',
  37. attributes.hasClass('fieldgroup') and not attributes.hasClass('form-composite') ? 'fieldset__legend--group',
  38. attributes.hasClass('form-composite') ? 'fieldset__legend--composite',
  39. title_display == 'invisible' ? 'fieldset__legend--invisible' : 'fieldset__legend--visible',
  40. ]
  41. %}
  42. {%
  43. set description_classes = [
  44. 'fieldset__description',
  45. ]
  46. %}
  47. <fieldset{{ glb_classes(attributes.addClass(classes)) }}>
  48. {# Always wrap fieldset legends in a <span> for CSS positioning. #}
  49. {% if legend.title %}
  50. <legend{{ glb_classes(legend.attributes.addClass(legend_classes)) }}>
  51. <span{{ glb_classes(legend_span.attributes.addClass(legend_span_classes)) }}>{{ legend.title }}</span>
  52. </legend>
  53. {% endif %}
  54. <div{{ glb_classes(content_attributes.addClass(wrapper_classes)) }}>
  55. {% if inline_items %}
  56. <div class="container-inline">
  57. {% endif %}
  58. {% if prefix %}
  59. <span class="fieldset__prefix">{{ prefix }}</span>
  60. {% endif %}
  61. {{ children }}
  62. {% if suffix %}
  63. <span class="fieldset__suffix">{{ suffix }}</span>
  64. {% endif %}
  65. {% if errors %}
  66. <div class="fieldset__error-message">
  67. {{ errors }}
  68. </div>
  69. {% endif %}
  70. {% if description.content %}
  71. <div{{ glb_classes(description.attributes.addClass(description_classes)) }}>{{ description.content }}</div>
  72. {% endif %}
  73. {% if inline_items %}
  74. </div>
  75. {% endif %}
  76. </div>
  77. </fieldset>