details.html.twig

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

Theme override for a details element.

Available variables

  • attributes: A list of HTML attributes for the details element.
  • errors: (optional) Any errors for this details element, may not be set.
  • title: (optional) The title of the element, may not be set.
  • description: (optional) The description of the element, may not be set.
  • children: (optional) The children of the element, may not be set.
  • value: (optional) The value of the element, may not be set.
  • accordion: whether the details element should look as an accordion.
  • accordion_item: whether the details element is an item of an accordion list.
  • disabled: whether the details is disabled.

See also

template_preprocess_details()

gin_preprocess_details()

File

core/themes/admin/templates/form/details.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override for a details element.
  5. *
  6. * Available variables
  7. * - attributes: A list of HTML attributes for the details element.
  8. * - errors: (optional) Any errors for this details element, may not be set.
  9. * - title: (optional) The title of the element, may not be set.
  10. * - description: (optional) The description of the element, may not be set.
  11. * - children: (optional) The children of the element, may not be set.
  12. * - value: (optional) The value of the element, may not be set.
  13. * - accordion: whether the details element should look as an accordion.
  14. * - accordion_item: whether the details element is an item of an accordion
  15. * list.
  16. * - disabled: whether the details is disabled.
  17. *
  18. * @see template_preprocess_details()
  19. * @see gin_preprocess_details()
  20. */
  21. #}
  22. {#
  23. Prefix 'details' class to avoid collision with Modernizr.
  24. @todo Remove prefix after https://www.drupal.org/node/2981732 has been solved.
  25. #}
  26. {% set show_description_toggle = description_toggle and description %}
  27. {%
  28. set classes = [
  29. 'gin-details',
  30. accordion ? 'gin-details--accordion',
  31. accordion_item ? 'gin-details--accordion-item',
  32. show_description_toggle ? 'help-icon__description-container',
  33. ]
  34. %}
  35. {%
  36. set content_wrapper_classes = [
  37. 'gin-details__wrapper',
  38. 'details-wrapper',
  39. accordion ? 'gin-details__wrapper--accordion',
  40. accordion_item ? 'gin-details__wrapper--accordion-item',
  41. ]
  42. %}
  43. {%
  44. set inner_wrapper_classes = [
  45. 'gin-details__content',
  46. accordion ? 'gin-details__content--accordion',
  47. accordion_item ? 'gin-details__content--accordion-item',
  48. ]
  49. %}
  50. {%
  51. set description_classes = [
  52. 'gin-details__description',
  53. disabled ? 'is-disabled',
  54. description_display == 'invisible' ? 'visually-hidden',
  55. ]
  56. %}
  57. <details{{ attributes.addClass(classes) }}>
  58. {%- if title -%}
  59. {%
  60. set summary_classes = [
  61. 'gin-details__summary',
  62. required ? 'js-form-required',
  63. required ? 'form-required',
  64. accordion ? 'gin-details__summary--accordion',
  65. accordion_item ? 'gin-details__summary--accordion-item',
  66. ]
  67. %}
  68. <summary{{ summary_attributes.addClass(summary_classes) }}>
  69. {{- title -}}
  70. <span class="required-mark"></span>
  71. {% if show_description_toggle %}
  72. {{ attach_library('gin/description_toggle') }}
  73. <button class="help-icon__description-toggle"></button>
  74. {% endif %}
  75. </summary>
  76. {%- endif -%}
  77. <div{{ content_attributes.addClass(content_wrapper_classes) }}>
  78. {% if accordion or accordion_item %}
  79. <div{{ create_attribute({class: inner_wrapper_classes}) }}>
  80. {% endif %}
  81. {% if errors %}
  82. <div class="form-item form-item--error-message">
  83. {{ errors }}
  84. </div>
  85. {% endif %}
  86. {%- if description -%}
  87. <div{{ create_attribute().addClass(description_classes) }}>{{ description }}</div>
  88. {%- endif -%}
  89. {%- if children -%}
  90. {{ children }}
  91. {%- endif -%}
  92. {%- if value -%}
  93. {{ value }}
  94. {%- endif -%}
  95. {% if accordion or accordion_item %}
  96. </div>
  97. {% endif %}
  98. </div>
  99. </details>

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