Introduction to Computation Rules

Computation rules can be set on a field in order to dynamically calculate its value based on the contents of other fields. This option is available using button [5] in your Site Form or Admin Form views.

Constructing your Computation

In the first "Computation" select field, you can determine which type of 'calculation' you would like to perform on your fields, which can be selected using the "Fields" select box directly below

Numeric

  • Average: will display the Average value (or Mean value) of the fields you select
  • Count: will display the number of fields you select
  • Format: works in conjunction with the Format / Precision option on the right. No calculation will be done on the fields, but they will be formatted depending on the Format / Precision option that is selected on the right.
  • Max: will display the maximum value of the fields you select
  • Min: will display the minimum value of the fields you select
  • Product(*): will multiply the values of all the fields you select together and display the result
  • Sum (+): will add the values of all the fields you selected and display the result

String

  • Concatenate: this option will merge or 'concatenate' the values of the fields selected. So, if your first field's value is "Hi" and the second selected field's value is "SEBLOD", the result will be "HiSEBLOD"

Custom: The custom computation option lets you define your own equation to perform on the fields selected below using standard PHP operators. Each field selected is referred to in alphabetical order, i.e. the first field is referred to as "a", the second as "b", the third as "c", and so on. When the "Custom" option is selected, a second field appears where you can select a pre-existing calculation, or you can choose -Free- and define your own calculation using the text field on the right.

Format / Precision

  • Ceil: will round your value up to the nearest whole integer
  • Floor: will round your value down to the nearest whole integer
  • Round: will round your value using standard rounding conventions
  • toFixed: will round your value to a pre-defined number of decimal places which can be entered in the text input box that appears when this option is selected

Trigger Event

  • Keyup: this will trigger the calculation immediately after your keyboard key is released.
  • Change: this will trigger the calculation immediately after a field's value is changed.

Using Custom Attributes

You can tick the "Custom Attribute" box next to the "Fields" selection options in order to define a custom attribute from each field that should be used in the calculation, rather than using the fields' value. If this box is ticked, when you add a field there will be a text input to the right where you can enter the name of the custom attribute to use. If this is left empty, the field's value will be used by default.