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/starterkit_theme/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 multiple value form element.

Available variables for all fields:

  • multiple: Whether there are multiple instances of the field.
  • disabled: Whether the input is disabled.

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()

claro_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/claro/templates/form/field-multiple-value-form.html.twig

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

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