You are here

form-element-label.html.twig in Open Social 8.8

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.
  • attributes: A list of HTML attributes for the label.

File

themes/socialbase/templates/form/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. * - element: an input element.
  8. * - title: The label's text.
  9. * - title_display: Elements title_display setting.
  10. * - description: element description.
  11. * - required: An indicator for whether the associated form element is required.
  12. * - attributes: A list of HTML attributes for the label.
  13. *
  14. * @see template_preprocess_form_element_label()
  15. *
  16. * @ingroup templates
  17. */
  18. #}
  19. {%-
  20. set classes = [
  21. 'control-label',
  22. title_display == 'after' ? 'option',
  23. title_display == 'invisible' ? 'sr-only',
  24. title_display == 'above' ? 'control-label--above',
  25. required ? 'js-form-required',
  26. required ? 'form-required',
  27. ]
  28. -%}
  29. {{ element }}
  30. {%- if title is not empty -%}
  31. <label{{ attributes.addClass(classes) }}>
  32. {{ title }}
  33. {%- if required and title_display != 'invisible' -%}
  34. <span class="form-required" title="{% trans %}This field is required{% endtrans %}">*</span>
  35. {%- endif -%}
  36. {%- if description -%}
  37. <p class="help-block">{{ description }}</p>
  38. {%- endif -%}
  39. </label>
  40. {%- endif -%}