form-element-label.html.twig in Zircon Profile 8
Same filename in this branch
Same filename and directory in other branches
Default theme implementation for a form element label.
Available variables:
- title: The label's text.
- title_display: Elements title_display setting.
- required: An indicator for whether the associated form element is required.
- attributes: A list of HTML attributes for the label.
See also
2 theme calls to form-element-label.html.twig
- Label::getInfo in core/
lib/ Drupal/ Core/ Render/ Element/ Label.php - Returns the element properties for this element.
- template_preprocess_form_element in core/
includes/ form.inc - Returns HTML for a form element. Prepares variables for form element templates.
File
core/modules/system/templates/form-element-label.html.twigView source
- {#
- /**
- * @file
- * Default theme implementation for a form element label.
- *
- * Available variables:
- * - title: The label's text.
- * - title_display: Elements title_display setting.
- * - required: An indicator for whether the associated form element is required.
- * - attributes: A list of HTML attributes for the label.
- *
- * @see template_preprocess_form_element_label()
- *
- * @ingroup themeable
- */
- #}
- {%
- set classes = [
- title_display == 'after' ? 'option',
- title_display == 'invisible' ? 'visually-hidden',
- required ? 'js-form-required',
- required ? 'form-required',
- ]
- %}
- {% if title is not empty or required -%}
- <label{{ attributes.addClass(classes) }}>{{ title }}</label>
- {%- endif %}