This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/modules/contrib/webform/templates/webform-section.html.twig
2018-11-23 12:29:20 +00:00

63 lines
1.9 KiB
Twig

{#
/**
* @file
* Default theme implementation for a webform section element and its children.
*
* Available variables:
* - attributes: HTML attributes for the <section> element.
* - errors: (optional) Any errors for this <section> element, may not be set.
* - required: Boolean indicating whether the <section> element is required.
* - title: The title/header of the section header.
* - title_attributes: HTML attributes to apply to the title/header element.
* - title_tag: The title/header HTML tag.
* - 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 .section-wrapper children.
* - suffix: The content to add after the .section-wrapper children.
*
* Copied from: fieldset.html.twig
*
* @see template_preprocess_webform_section()
*
* @ingroup themeable
*/
#}
{%
set classes = [
'js-form-item',
'form-item',
'js-form-wrapper',
'form-wrapper',
'webform-section',
]
%}
<section{{ attributes.addClass(classes) }}>
{%
set title_classes = [
'webform-section-title',
required ? 'js-form-required',
required ? 'form-required',
]
%}
<{{ title_tag }}{{ title_attributes.addClass(title_classes) }}>{{ title }}</{{ title_tag }}>
<div class="webform-section-wrapper">
{% if errors %}
<div>
{{ errors }}
</div>
{% endif %}
{% if description.content %}
<div{{ description.attributes.addClass('description') }}>{{ description.content }}</div>
{% endif %}
{% if prefix %}
<span class="field-prefix">{{ prefix }}</span>
{% endif %}
{{ children }}
{% if suffix %}
<span class="field-suffix">{{ suffix }}</span>
{% endif %}
</div>
</section>