Setting Up Fields For Calculations
To perform calculations using the Divi Form Builder plugin, you need to collect user inputs through specific fields. The following field types support user input for calculations:
Setting Up Fields for Calculations
1. Assign Field IDs
Every field used in calculations must have a unique Field ID. Field IDs should only include English letters, numbers, and underscores, and must start with a letter. It is recommended to use all lowercase letters for Field IDs.
2. Using Number Input Field
This field allows users to input numbers directly. You can set a default value to be used if the user leaves the field empty. If unset, the default value is 0.
Avoid using normal text input fields for calculations as they can accept non-numeric characters, which would be invalid for calculations and might crash the form.
3. Using Select Dropdown, Radio Buttons, and Checkbox Fields
- For these fields, you need to enable the option
Is this field for calculation
in the field settings. - Enter the calculation values for each option one by one. Negative values are supported and should be entered with a minus sign in front of the number eg
-5
for negative 5.
For checkboxes where users can select multiple options, the values corresponding to the selected options will be summed up.
In the next documentation section, we will learn how to utilize these field values in your calculations.