form-element.html.twig

Same filename in this branch
  1. 11.x core/profiles/demo_umami/themes/umami/templates/classy/form/form-element.html.twig
  2. 11.x core/themes/stable9/templates/form/form-element.html.twig
  3. 11.x core/themes/claro/templates/form-element.html.twig
  4. 11.x core/themes/starterkit_theme/templates/form/form-element.html.twig
  5. 11.x core/modules/system/templates/form-element.html.twig
Same filename and directory in other branches
  1. 10 core/profiles/demo_umami/themes/umami/templates/classy/form/form-element.html.twig
  2. 10 core/themes/stable9/templates/form/form-element.html.twig
  3. 10 core/themes/claro/templates/form-element.html.twig
  4. 10 core/themes/starterkit_theme/templates/form/form-element.html.twig
  5. 10 core/modules/system/templates/form-element.html.twig
  6. 9 core/profiles/demo_umami/themes/umami/templates/classy/form/form-element.html.twig
  7. 9 core/themes/stable9/templates/form/form-element.html.twig
  8. 9 core/themes/seven/templates/classy/form/form-element.html.twig
  9. 9 core/themes/claro/templates/form-element.html.twig
  10. 9 core/themes/bartik/templates/classy/form/form-element.html.twig
  11. 9 core/themes/stable/templates/form/form-element.html.twig
  12. 9 core/themes/starterkit_theme/templates/form/form-element.html.twig
  13. 9 core/themes/classy/templates/form/form-element.html.twig
  14. 9 core/modules/system/templates/form-element.html.twig
  15. 8.9.x core/profiles/demo_umami/themes/umami/templates/classy/form/form-element.html.twig
  16. 8.9.x core/themes/seven/templates/classy/form/form-element.html.twig
  17. 8.9.x core/themes/claro/templates/form-element.html.twig
  18. 8.9.x core/themes/bartik/templates/classy/form/form-element.html.twig
  19. 8.9.x core/themes/stable/templates/form/form-element.html.twig
  20. 8.9.x core/themes/classy/templates/form/form-element.html.twig
  21. 8.9.x core/modules/system/templates/form-element.html.twig
  22. main core/profiles/demo_umami/themes/umami/templates/classy/form/form-element.html.twig
  23. main core/themes/stable9/templates/form/form-element.html.twig
  24. main core/themes/claro/templates/form-element.html.twig
  25. main core/themes/starterkit_theme/templates/form/form-element.html.twig
  26. main core/modules/system/templates/form-element.html.twig
  27. main core/themes/admin/templates/form/form-element.html.twig

Theme override for a form element.

See also

template_preprocess_form_element()

File

core/themes/admin/templates/form/form-element.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override for a form element.
  5. *
  6. * @see template_preprocess_form_element()
  7. */
  8. #}
  9. {#
  10. Most of core-provided js assumes that the CSS class pattern js-form-item-[something] or
  11. js-form-type-[something] exists on form items. We have to keep them.
  12. #}
  13. {% set show_description_toggle = description_toggle and description.content %}
  14. {%
  15. set classes = [
  16. 'js-form-item',
  17. 'form-item',
  18. 'js-form-type-' ~ type|clean_class,
  19. 'form-type--' ~ type|clean_class,
  20. type in ['checkbox', 'radio'] ? 'form-type--boolean',
  21. 'js-form-item-' ~ name|clean_class,
  22. 'form-item--' ~ name|clean_class,
  23. title_display not in ['after', 'before'] ? 'form-item--no-label',
  24. disabled == 'disabled' ? 'form-item--disabled',
  25. errors ? 'form-item--error',
  26. show_description_toggle ? 'help-icon__description-container'
  27. ]
  28. %}
  29. {%
  30. set description_classes = [
  31. 'form-item__description',
  32. description_display == 'invisible' ? 'visually-hidden',
  33. ]
  34. %}
  35. <div{{ attributes.addClass(classes) }}>
  36. {% if label_display in ['before', 'invisible'] %}
  37. {% if show_description_toggle %}
  38. <div class="help-icon">
  39. {{ label }}
  40. {{ attach_library('gin/description_toggle') }}
  41. <button class="help-icon__description-toggle"></button>
  42. </div>
  43. {% else %}
  44. {{ label }}
  45. {% endif %}
  46. {% endif %}
  47. {% if show_description_toggle %}
  48. <div class="help-icon__element-has-description">
  49. {% endif %}
  50. {% if prefix is not empty %}
  51. <span class="form-item__prefix{{disabled == 'disabled' ? ' is-disabled'}}">{{ prefix }}</span>
  52. {% endif %}
  53. {% if description_display == 'before' and description.content %}
  54. <div{{ description.attributes.addClass(description_classes) }}>
  55. {{ description.content }}
  56. </div>
  57. {% endif %}
  58. {{ children }}
  59. {% if suffix is not empty %}
  60. <span class="form-item__suffix{{disabled == 'disabled' ? ' is-disabled'}}">{{ suffix }}</span>
  61. {% endif %}
  62. {% if label_display == 'after' %}
  63. {% if show_description_toggle %}
  64. <div class="help-icon">
  65. {{ label }}
  66. {{ attach_library('gin/description_toggle') }}
  67. <button class="help-icon__description-toggle"></button>
  68. </div>
  69. {% else %}
  70. {{ label }}
  71. {% endif %}
  72. {% endif %}
  73. {% if show_description_toggle %}
  74. </div>
  75. {% endif %}
  76. {% if errors %}
  77. <div class="form-item__error-message">
  78. {{ errors }}
  79. </div>
  80. {% endif %}
  81. {% if description_display in ['after', 'invisible'] and description.content %}
  82. <div{{ description.attributes.addClass(description_classes) }}>
  83. {{ description.content }}
  84. </div>
  85. {% endif %}
  86. </div>

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