You are here

field-multiple-value-form.html.twig in Drupal 10

Theme override for an individual form element.

Available variables for all fields:

  • multiple: Whether there are multiple instances of the field.

Available variables for single cardinality fields:

  • elements: Form elements to be rendered.

Available variables when there are multiple fields.

  • table: Table of field items.
  • description: The description element containing the following properties:
    • content: The description content of the form element.
    • attributes: HTML attributes to apply to the description container.
  • button: "Add another item" button.

File

core/themes/olivero/templates/form/field-multiple-value-form.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override for an individual form element.
  5. *
  6. * Available variables for all fields:
  7. * - multiple: Whether there are multiple instances of the field.
  8. *
  9. * Available variables for single cardinality fields:
  10. * - elements: Form elements to be rendered.
  11. *
  12. * Available variables when there are multiple fields.
  13. * - table: Table of field items.
  14. * - description: The description element containing the following properties:
  15. * - content: The description content of the form element.
  16. * - attributes: HTML attributes to apply to the description container.
  17. * - button: "Add another item" button.
  18. *
  19. * @see template_preprocess_field_multiple_value_form()
  20. *
  21. * @ingroup themeable
  22. */
  23. #}
  24. {% if multiple %}
  25. {%
  26. set classes = [
  27. 'js-form-item',
  28. 'form-item'
  29. ]
  30. %}
  31. {%
  32. set description_classes = [
  33. 'form-item__description',
  34. disabled ? 'is-disabled',
  35. ]
  36. %}
  37. <div{{ attributes.addClass(classes) }}>
  38. {{ table }}
  39. {% if description.content %}
  40. <div{{ description.attributes.addClass(description_classes) }}>{{ description.content }}</div>
  41. {% endif %}
  42. {% if button %}
  43. <div class="form-actions">{{ button }}</div>
  44. {% endif %}
  45. </div>
  46. {% else %}
  47. {% for element in elements %}
  48. {{ element }}
  49. {% endfor %}
  50. {% endif %}

Related topics