You are here

form-element-label--gin-lb.html.twig in Gin Layout Builder 1.0.x

Theme override 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.

File

templates/form/form-element-label--gin-lb.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override 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. #}
  15. {%
  16. set classes = [
  17. 'form-item__label',
  18. title_display == 'after' ? 'option',
  19. title_display == 'invisible' ? 'visually-hidden',
  20. required ? 'js-form-required',
  21. required ? 'form-required',
  22. ]
  23. %}
  24. {% if title is not empty or required -%}
  25. <label{{ glb_classes(attributes.addClass(classes)) }}>{{ title }}</label>
  26. {%- endif %}