You are here

Webform

Calculate a value from options field in Webform custom composite element with Twig - Drupal 8

Recently, I was creating an event registration Webform. I created a custom composite field with the fields needed for each registrant: first name, last name, and a set of three radio options for their organization status: member, non-member, membership fee included in event registration. Each status has a different registration fee.

I then wanted to create a computed Twig field that would calculate the total registration fee by getting the data from the chosen radio option for each attendee and adding it up. This proved surprisingly tricky.