This module adds support of Calculations for the Webform module.

Features

  • Use custom calculations per form and per form step.
  • Use custom logic and/or existing libraries to calculate result.
  • Theme results (the module supports result templates for single page webforms, multiple pages webforms and per step templates).
  • Save calculated results and view them at the regular form submission page.


Requirements


Installation

  • Copy the entire webform_calculation directory the Drupal sites/all/modules directory
  • Login as an administrator. Enable the module in the "Administer" -> "Modules" (or you can use drush command: drush en webform_calculation).

Drupal 8

  • Make sure Webform is installed.
  • Create /libraries/Calculation directory. The module looks for .php files with helper function or classes here.
  • There is "Example: Webform Calculation" created after installing the module. Default Twig template is used to show how submitted values may be accessed. Also, renders evaluated result.

To make evaluations the module uses "Custom composite" field which consists of 2 textarea fields: with formula and evaluated result. Also, the field uses custom property "calculation: true" which lets the module know that here is a formula and a place to store evaluations. The property has to be set to make the formula running.

Formula is set as field default value. It's simple executable code which may use submitted values (using its machine name as variable).

The module uses "Webform Calculation" handler to process user input, make evaluations and set them to the submission. The handler has to be attached to the form created manually.

Please feel free to export and import source code of the example webform to create custom forms.

Credits

The project has been sponsored by @culfin.

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • caution Maintenance fixes only
    Considered feature-complete by its maintainers.
  • chart icon230 sites report using this module
  • Created by aprogs on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    There are currently no supported stable releases.

Releases