Webform - Custom Composite Element

71 Views Asked by At

I have a Custom Composite Element key = "attendance_program_detail".

I am trying to create a computed Twig of Total hours.

The sub element is labeled Hours (Key = "hrs").

I don't know how to create a loop to add all the subelements that may be entered.

{{data.attendance_program_detail.hrs}}

Any assistance would be greatly appreciated.

1

There are 1 best solutions below

0
Bert On

I found the following. Inserted the proper key names and it works fine.

{% for item in data.composite_element_key %}
  {% set sum = item.subelement_key + sum ?? 0 %}
  {% if loop.last %}{{ sum }}{% endif %}
{% endfor %}

Thanks!