field-multiple-value-form.html.twig

Same filename in this branch
  1. 11.x core/themes/olivero/templates/form/field-multiple-value-form.html.twig
  2. 11.x core/themes/stable9/templates/form/field-multiple-value-form.html.twig
  3. 11.x core/themes/claro/templates/form/field-multiple-value-form.html.twig
  4. 11.x core/modules/system/templates/field-multiple-value-form.html.twig
Same filename in other branches
  1. 9 core/themes/olivero/templates/form/field-multiple-value-form.html.twig
  2. 9 core/themes/stable9/templates/form/field-multiple-value-form.html.twig
  3. 9 core/themes/claro/templates/form/field-multiple-value-form.html.twig
  4. 9 core/themes/stable/templates/form/field-multiple-value-form.html.twig
  5. 9 core/themes/starterkit_theme/templates/form/field-multiple-value-form.html.twig
  6. 9 core/themes/classy/templates/form/field-multiple-value-form.html.twig
  7. 9 core/modules/system/templates/field-multiple-value-form.html.twig
  8. 8.9.x core/themes/claro/templates/form/field-multiple-value-form.html.twig
  9. 8.9.x core/themes/stable/templates/form/field-multiple-value-form.html.twig
  10. 8.9.x core/themes/classy/templates/form/field-multiple-value-form.html.twig
  11. 8.9.x core/modules/system/templates/field-multiple-value-form.html.twig
  12. 10 core/themes/olivero/templates/form/field-multiple-value-form.html.twig
  13. 10 core/themes/stable9/templates/form/field-multiple-value-form.html.twig
  14. 10 core/themes/claro/templates/form/field-multiple-value-form.html.twig
  15. 10 core/themes/starterkit_theme/templates/form/field-multiple-value-form.html.twig
  16. 10 core/modules/system/templates/field-multiple-value-form.html.twig

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.

See also

template_preprocess_field_multiple_value_form()

1 theme call to field-multiple-value-form.html.twig
WidgetBase::formMultipleElements in core/lib/Drupal/Core/Field/WidgetBase.php
Special handling to create form elements for multiple values.

File

core/themes/starterkit_theme/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. #}
  22. {% if multiple %}
  23. {%
  24. set classes = [
  25. 'js-form-item',
  26. 'form-item'
  27. ]
  28. %}
  29. <div{{ attributes.addClass(classes) }}>
  30. {{ table }}
  31. {% if description.content %}
  32. <div{{ description.attributes.addClass('description') }} >{{ description.content }}</div>
  33. {% endif %}
  34. {% if button %}
  35. <div class="clearfix">{{ button }}</div>
  36. {% endif %}
  37. </div>
  38. {% else %}
  39. {% for element in elements %}
  40. {{ element }}
  41. {% endfor %}
  42. {% endif %}

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