Formtastic Documentation

Using special elements

In the form designer there are different input elements, group elements, structure elements and special elements available. The following list explains all special elements and their specific setting options:

1. Calculation

A formula can be entered in the calculation field so that the result is automatically calculated from the entries in other fields when it is filled in. The 4 basic arithmetic operations (+, – , *, /) can be used. The number placeholders available in your form are highlighted in grey below.
The following 3 formula types are available for selection:

  • Numbers: For calculating a number from input fields or number sliders according to your formula. The number of decimal places and the type of rounding can be specified.
  • Duration: To calculate a duration from date or time entries.
    Formula example: #endtime# – #starttime#
  • Date and time: To add or subtract a period, e.g. 14 days or 3 hours, from a date and time entry.
    Formula example: #time# + duration(0:14:3:0:0)

Example of a working time table. The duration in hours was calculated automatically:

The following functions are available:

  • average: calculates average of field values placed inside Table or Expandable group fields
  • sum: calculates sum of field values placed inside Table or Expandable group fields
  • mod: returns the positive value of a number
  • sqrt: returns the square root of a number
  • cbrt: returns the cubic root of a number
  • duration(y:d:h:m:s): adds a duration. y: year, d: day, h: hour, m: minute and s: second. For example duration(1:0:0:4:5) will return a duration of one year, four minutes and five seconds.
  • extractDuration: returns a duration as a number in the chosen time unit (y, d, h, m, s). Example: extractDuration(#duration_field#:h) – Returns the duration in hours from the specified duration field.

Functions can also be nested, e.g. extractDuration(sum(#endtime#-#starttime#):h)

If you want to insert a decimal number into the formula (e.g. as a factor), please use a dot instead of a comma as the decimal separator. The normal dot-before-dash rule applies, so brackets can also be used.
Formula example: (#number1# + #number2#) * 2.5

2. PDF File

Inserts a PDF file into the form. This PDF can then be opened by clicking on it during filling.

Page content