form-element-label.html.twig

Same filename in this branch
  1. 8.9.x core/profiles/demo_umami/themes/umami/templates/classy/form/form-element-label.html.twig
  2. 8.9.x core/themes/seven/templates/classy/form/form-element-label.html.twig
  3. 8.9.x core/themes/claro/templates/form-element-label.html.twig
  4. 8.9.x core/themes/bartik/templates/classy/form/form-element-label.html.twig
  5. 8.9.x core/themes/stable/templates/form/form-element-label.html.twig
  6. 8.9.x core/themes/classy/templates/form/form-element-label.html.twig
Same filename in other branches
  1. 9 core/profiles/demo_umami/themes/umami/templates/classy/form/form-element-label.html.twig
  2. 9 core/themes/stable9/templates/form/form-element-label.html.twig
  3. 9 core/themes/seven/templates/classy/form/form-element-label.html.twig
  4. 9 core/themes/claro/templates/form-element-label.html.twig
  5. 9 core/themes/bartik/templates/classy/form/form-element-label.html.twig
  6. 9 core/themes/stable/templates/form/form-element-label.html.twig
  7. 9 core/themes/starterkit_theme/templates/form/form-element-label.html.twig
  8. 9 core/themes/classy/templates/form/form-element-label.html.twig
  9. 9 core/modules/system/templates/form-element-label.html.twig
  10. 10 core/profiles/demo_umami/themes/umami/templates/components/form/form-element-label.html.twig
  11. 10 core/themes/stable9/templates/form/form-element-label.html.twig
  12. 10 core/themes/claro/templates/form-element-label.html.twig
  13. 10 core/themes/starterkit_theme/templates/form/form-element-label.html.twig
  14. 10 core/modules/system/templates/form-element-label.html.twig
  15. 11.x core/profiles/demo_umami/themes/umami/templates/components/form/form-element-label.html.twig
  16. 11.x core/themes/stable9/templates/form/form-element-label.html.twig
  17. 11.x core/themes/claro/templates/form-element-label.html.twig
  18. 11.x core/themes/starterkit_theme/templates/form/form-element-label.html.twig
  19. 11.x core/modules/system/templates/form-element-label.html.twig

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

template_preprocess_form_element_label()

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.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for a form element label.
  5. *
  6. * Available variables:
  7. * - title: The label's text.
  8. * - title_display: Elements title_display setting.
  9. * - required: An indicator for whether the associated form element is required.
  10. * - attributes: A list of HTML attributes for the label.
  11. *
  12. * @see template_preprocess_form_element_label()
  13. *
  14. * @ingroup themeable
  15. */
  16. #}
  17. {%
  18. set classes = [
  19. title_display == 'after' ? 'option',
  20. title_display == 'invisible' ? 'visually-hidden',
  21. required ? 'js-form-required',
  22. required ? 'form-required',
  23. ]
  24. %}
  25. {% if title is not empty or required -%}
  26. <label{{ attributes.addClass(classes) }}>{{ title }}</label>
  27. {%- endif %}

Related topics


Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.