Override Bulma's form-element-label template to add form-label class
This commit is contained in:
parent
cf4ce9f785
commit
9a5d29d1e8
1 changed files with 53 additions and 0 deletions
53
agaric/templates/elements/form-element-label.html.twig
Normal file
53
agaric/templates/elements/form-element-label.html.twig
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
{#
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Default theme implementation for a form element label.
|
||||||
|
*
|
||||||
|
* Available variables:
|
||||||
|
* - element: an input element.
|
||||||
|
* - title: The label's text.
|
||||||
|
* - title_display: Elements title_display setting.
|
||||||
|
* - description: element description.
|
||||||
|
* - required: An indicator for whether the associated form element is required.
|
||||||
|
* - is_checkbox: Whether the label is outputted in checkbox context.
|
||||||
|
* - is_radio: Whether the label is outputted in radio button context.
|
||||||
|
* - attributes: A list of HTML attributes for the label.
|
||||||
|
*
|
||||||
|
* @ingroup templates
|
||||||
|
*
|
||||||
|
* @see template_preprocess_form_element_label()
|
||||||
|
*/
|
||||||
|
#}
|
||||||
|
{%-
|
||||||
|
set classes = [
|
||||||
|
'form-label',
|
||||||
|
'label',
|
||||||
|
'control-label',
|
||||||
|
title_display == 'after' ? 'option',
|
||||||
|
title_display == 'invisible' and not (is_checkbox or is_radio) ? 'sr-only',
|
||||||
|
required ? 'js-form-required',
|
||||||
|
required ? 'form-required',
|
||||||
|
tag,
|
||||||
|
color,
|
||||||
|
size,
|
||||||
|
]
|
||||||
|
-%}
|
||||||
|
{% if title is not empty and title_display == 'invisible' and (is_checkbox or is_radio) -%}
|
||||||
|
{#
|
||||||
|
Clear but preserve label text as attribute (e.g. for screen readers) for
|
||||||
|
checkboxes/radio buttons when it actually should be invisible.
|
||||||
|
#}
|
||||||
|
{%- set attributes = attributes.setAttribute('title', title) -%}
|
||||||
|
{%- set title = null -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{#
|
||||||
|
Labels for single checkboxes/radios contain the element itself and thus have
|
||||||
|
always to be rendered regardless of whether they have a title or not.
|
||||||
|
#}
|
||||||
|
{%- if title is not empty or is_checkbox or is_radio -%}
|
||||||
|
<label{{ attributes.addClass(classes) }}>{{ element }}{{ title }}
|
||||||
|
{%- if description -%}
|
||||||
|
<p class="help-block">{{ description }}</p>
|
||||||
|
{%- endif -%}
|
||||||
|
</label>
|
||||||
|
{%- endif -%}
|
Loading…
Reference in a new issue