fieldset.html.twig
Same filename in this branch
- 9 core/themes/olivero/templates/form/fieldset.html.twig
- 9 core/themes/stable9/templates/form/fieldset.html.twig
- 9 core/themes/seven/templates/classy/form/fieldset.html.twig
- 9 core/themes/claro/templates/fieldset.html.twig
- 9 core/themes/bartik/templates/classy/form/fieldset.html.twig
- 9 core/themes/stable/templates/form/fieldset.html.twig
- 9 core/themes/starterkit_theme/templates/form/fieldset.html.twig
- 9 core/themes/classy/templates/form/fieldset.html.twig
- 9 core/modules/system/templates/fieldset.html.twig
Same filename in other branches
- 8.9.x core/profiles/demo_umami/themes/umami/templates/classy/form/fieldset.html.twig
- 8.9.x core/themes/seven/templates/classy/form/fieldset.html.twig
- 8.9.x core/themes/claro/templates/fieldset.html.twig
- 8.9.x core/themes/bartik/templates/classy/form/fieldset.html.twig
- 8.9.x core/themes/stable/templates/form/fieldset.html.twig
- 8.9.x core/themes/classy/templates/form/fieldset.html.twig
- 8.9.x core/modules/system/templates/fieldset.html.twig
- 10 core/profiles/demo_umami/themes/umami/templates/classy/form/fieldset.html.twig
- 10 core/themes/olivero/templates/form/fieldset.html.twig
- 10 core/themes/stable9/templates/form/fieldset.html.twig
- 10 core/themes/claro/templates/fieldset.html.twig
- 10 core/themes/starterkit_theme/templates/form/fieldset.html.twig
- 10 core/modules/system/templates/fieldset.html.twig
- 11.x core/profiles/demo_umami/themes/umami/templates/classy/form/fieldset.html.twig
- 11.x core/themes/olivero/templates/form/fieldset.html.twig
- 11.x core/themes/stable9/templates/form/fieldset.html.twig
- 11.x core/themes/claro/templates/fieldset.html.twig
- 11.x core/themes/starterkit_theme/templates/form/fieldset.html.twig
- 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 fieldset 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.
- description_display: Description display setting. It can have these values:
- before: The description is output before the element.
- after: The description is output after the element (default).
- invisible: The description is output after the element, hidden visually but available to screen readers.
- 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/
profiles/ demo_umami/ themes/ umami/ templates/ classy/ form/ fieldset.html.twig
View source
- {#
- /**
- * @file
- * 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 fieldset 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.
- * - description_display: Description display setting. It can have these values:
- * - before: The description is output before the element.
- * - after: The description is output after the element (default).
- * - invisible: The description is output after the element, hidden visually
- * but available to screen readers.
- * - 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 template_preprocess_fieldset()
- */
- #}
- {%
- set classes = [
- 'js-form-item',
- 'form-item',
- 'js-form-wrapper',
- 'form-wrapper',
- ]
- %}
- <fieldset{{ attributes.addClass(classes) }}>
- {%
- set legend_span_classes = [
- 'fieldset-legend',
- required ? 'js-form-required',
- required ? 'form-required',
- ]
- %}
- {# Always wrap fieldset legends in a <span> for CSS positioning. #}
- <legend{{ legend.attributes }}>
- <span{{ legend_span.attributes.addClass(legend_span_classes) }}>{{ legend.title }}</span>
- </legend>
- <div class="fieldset-wrapper">
- {% if description_display == 'before' and description.content %}
- <div{{ description.attributes.addClass('description') }}>{{ description.content }}</div>
- {% endif %}
- {% if errors %}
- <div class="form-item--error-message">
- <strong>{{ errors }}</strong>
- </div>
- {% endif %}
- {% if prefix %}
- <span class="field-prefix">{{ prefix }}</span>
- {% endif %}
- {{ children }}
- {% if suffix %}
- <span class="field-suffix">{{ suffix }}</span>
- {% endif %}
- {% if description_display in ['after', 'invisible'] and description.content %}
- <div{{ description.attributes.addClass('description') }}>{{ description.content }}</div>
- {% endif %}
- </div>
- </fieldset>
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.