form-element--new-storage-type.html.twig

Same filename in this branch
  1. 11.x core/themes/stable9/templates/admin/form-element--new-storage-type.html.twig
Same filename in other branches
  1. 10 core/themes/stable9/templates/admin/form-element--new-storage-type.html.twig
  2. 10 core/modules/field_ui/templates/form-element--new-storage-type.html.twig

Default theme implementation for a storage type option form element.

Available variables:

  • attributes: HTML attributes for the containing element.
  • errors: (optional) Any errors for this form element, may not be set.
  • label: A rendered label element.
  • description: (optional) A list of description properties containing:
    • content: A description of the form element, may not be set.
    • attributes: (optional) A list of HTML attributes to apply to the description content wrapper. Will only be set when description is set.
  • variant: specifies option type. Typically 'field-option' or 'field-suboption'.

See also

template_preprocess_form_element()

File

core/modules/field_ui/templates/form-element--new-storage-type.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for a storage type option form element.
  5. *
  6. * Available variables:
  7. * - attributes: HTML attributes for the containing element.
  8. * - errors: (optional) Any errors for this form element, may not be set.
  9. * - label: A rendered label element.
  10. * - description: (optional) A list of description properties containing:
  11. * - content: A description of the form element, may not be set.
  12. * - attributes: (optional) A list of HTML attributes to apply to the
  13. * description content wrapper. Will only be set when description is set.
  14. * - variant: specifies option type. Typically 'field-option' or 'field-suboption'.
  15. *
  16. * @see template_preprocess_form_element()
  17. *
  18. * @ingroup themeable
  19. */
  20. #}
  21. {%
  22. set classes = [
  23. errors ? 'form-item--error',
  24. variant ? variant ~ '__item'
  25. ]
  26. %}
  27. <div{{ attributes.addClass(classes) }}>
  28. {% if variant == 'field-option' %}
  29. {{ label }}
  30. <div{{ description.attributes }}>
  31. {{ description.content }}
  32. </div>
  33. {% endif %}
  34. {{ children }}
  35. {% if variant == 'field-suboption' %}
  36. {{ label }}
  37. <div{{ description.attributes.addClass(description_classes) }}>
  38. {{ description.content }}
  39. </div>
  40. {% endif %}
  41. {% if errors %}
  42. <div class="form-item--error-message">
  43. {{ errors }}
  44. </div>
  45. {% endif %}
  46. </div>

Related topics


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