You are here

field-multiple-value-form--gin-lb.html.twig in Gin Layout Builder 1.0.x

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.

File

templates/form/field-multiple-value-form--gin-lb.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{{ glb_classes(attributes.addClass(classes)) }}>
  40. {{ table }}
  41. {% if description.content %}
  42. <div{{ glb_classes(description.attributes.addClass(description_classes)) }} >{{ description.content }}</div>
  43. {% endif %}
  44. {% if button %}
  45. <div class="glb-form-actions">{{ button }}</div>
  46. {% endif %}
  47. </div>
  48. {% else %}
  49. {% for element in elements %}
  50. {{ element }}
  51. {% endfor %}
  52. {% endif %}