Override Bulma's fieldset template to add form-label class to form label

This commit is contained in:
benjamin melançon 2018-12-11 12:09:01 -05:00
parent 6b06a10bb4
commit cf4ce9f785

View file

@ -0,0 +1,64 @@
{#
/**
* @file
* 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> element.
* - 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.
*
* @see template_preprocess_fieldset()
*
* @ingroup themeable
*/
#}
{%
set classes = [
'panel',
'js-form-item',
'form-item',
'js-form-wrapper',
'form-wrapper',
]
%}
<nav{{ attributes.addClass(classes) }}>
{%
set legend_span_classes = [
'form-label',
'panel-heading',
'fieldset-legend',
required ? 'js-form-required',
required ? 'form-required',
]
%}
<p{{ legend_span.attributes.addClass(legend_span_classes) }}>{{ legend.title }}</p>
<div class="panel-block fieldset-wrapper">
{% if errors %}
<div>
{{ errors }}
</div>
{% endif %}
{% if prefix %}
<span class="field-prefix">{{ prefix }}</span>
{% endif %}
{{ children }}
{% if suffix %}
<span class="field-suffix">{{ suffix }}</span>
{% endif %}
{% if description.content %}
<div{{ description.attributes.addClass('description') }}>{{ description.content }}</div>
{% endif %}
</div>
</nav>