Calculated Field

The Calculated Field can take the values from the form fields and meta fields and use them to perform operations.

calculated field

General Settings

This settings tab includes the basic customization fields:

general settings
  • FIELD LABEL — a name that appears above the field and is visible to users;
  • FORM FIELD NAME — a value that is used as an ID of this field. By default, it is generated from the FIELD LABEL value, but it can be changed if needed.
NOTE

The FORM FIELD NAME value should be unique for the page; it can have no spaces and contain only lowercase Latin letters, numbers, and “-” and “_” symbols.

  • FIELD DESCRIPTION — a description displayed under the field. It can be added to explain how to complete the field.

Field Settings

A set of options that allows customizing the input of the field:

the first part of the field settings
  • VALUE TYPE — a value type stored in the Calculated Field. There are two options available: “as Number” and “as String”.

As Number

With the “as Number” VALUE TYPE, the Calculated Field will calculate the numeric values taken from the form fields.

These numeric values can be set in the settings of the needed field. Some of the fields have corresponding customization fields: the CALCULATE field for the Select, Radio, and Checkbox Fields, VALUE FOR CALCULATED FIELD for the Advanced Choices Field, and CALCULATED VALUE for the Switcher Field.

NOTE

If the VALUE TYPE is changed from “as Number” to “as String,” usual values will be pulled for concatenation. More about it can be checked in the next “as String” part of the overview.

When this VALUE TYPE is used, the value should be put within “%” characters. The formula will look similar to this:

%first_field% + %second_field%

NOTE

The provided formula is an example. The formula should be set individually depending on the fields added to the form.

  • DECIMAL PLACES NUMBER — the number of the digits that will be displayed to the right from the decimal point;
  • DECIMALS SEPARATOR — the separator put after the decimals. By default, it is set to “.”;
the second part of the field settings
  • THOUSANDS SEPARATOR — the separator put after the decimals. By default, there is no separator set;
  • CALCULATED VALUE PREFIX — the text that will be shown before the resulting value here;
  • CALCULATED VALUE SUFFIX — the text that will be displayed after the calculated value.

Also, check more about Advanced Math Calculations.

As String

If selected, this option can concatenate string values. For example, the “as String” VALUE TYPE can be added to summarize the content completed in the form.

In this case, the set VALUE will be taken from the fields to make concatenations and not its CALCULATE value.

NOTE

If the “as String” VALUE TYPE is changed to “as Number”, the Calculated Field numeric values will be pulled for concatenation, as mentioned above in the “as Number” part of the overview.

If one selects the “as String” option, the values should be put inside the single or double quotes. For instance, like:

‘%first_field% %second_field%’

or

‘%first_field%’ + ‘%second_field%’

NOTE

The provided formula is an example. The formula should be set individually depending on the fields added to the form.

With the “as String” option selected as VALUE TYPE, no additional settings are displayed. However, there is a common customization field left for both “as Number” and “as String” VALUE TYPES:

as string value type
  • Hidden — a toggle that can be activated to make the current field invisible to users.

Style Settings

NOTE

This tab becomes available only if the JetStyleManager plugin is installed and activated.

To open the style settings, one should press the “brush” button.

With the Style tab, the following settings can be customized:

style settings

How to Perform Calculation and Concatenation

To perform calculations, one should put the formula in the Calculated Field.

As Number

If the “as Number” FIELD TYPE is selected, the following types of values can be used in the formula:

  • Static numbers — those could be either whole or fraction numbers;
  • Form field value — to get the value, the macro code %field_name% should be used, where “field_name” is the title you put to the FORM FIELD NAME bar;
  • Meta field value — the value will be taken from the meta field that is attached to the post where you have placed the form. To get the value, use the macro code %META::field_name%, where “field_name” is the name of the field.

Also, once the “wrench” icon above the Calculated Field is clicked, a list of macros is available. There, the form field macros and extra macros, including date operations, can be found.

You can do all sorts of mathematical operations with those values. Just type the formula into the Calculated Field text area. For example, let’s take a close look at the formula:

%quantity% * %META::price% + 2

This means that the field will take the value from the “quantity” form field, multiply it by the value of the “price” meta field, and add 2 to it.

In the Calculated Field formula, one can also add conditions for which the ternary operators can be used. More information can be checked in the How to Use Conditional Formulas in the Calculated Field tutorial.

Despite the fact that the formula is put into the field’s text area during editing, the users will see only the result of the calculations. The features of the Field tab allow customizing the look of that result:

calculation formula

As String

If the “as String” FIELD TYPE is selected, the fields from the current form can be concatenated.

For instance, two Text Fields can be concatenated with the following formula:

 ‘%first_name%’ + ‘%last_name%’

where “first_name’” and “last_name” are the FORM FIELD NAMES of the needed fields.

concatenation formula

Or, one can add a custom text before or after the values. For instance, the form includes two fields: Text Field with a “your_name” FORM FIELD VALUE and Calculated Field with the following formula inside:

‘Full name: %your_name%’

With this formula, a value put inside the “Your name” Text Field on the front end will be immediately displayed after the “Full name:” string.

concatenation formula with text field

That’s all about the Calculated Field available with the JetFormBuilder plugin for WordPress.