Forms (Configurators)

Forms – also referred to as Configurators – is a structure that contains a set of input fields. You can create your own forms and include these in your logics. This way it is easy to separate you pricing calculations from input generations, and to reuse inputs across multiple logics.

Additionally, forms also allow for a larger degree of freedom than inputs generated in the input generation mode. For example, you can have input fields appear, disappear, or change according to what other input the end user provides.

embedded form

To create a form, create a logic with default logic nature and return instances of ConfiguratorEntry and/or ConfiguratorEntryArray from its elements.

Including Forms in Other Logics

To include a form in your logic, build an input that references the form by its name:

def formFieldSet = api.createConfiguratorEntry() formFieldSet.inputs = [ api.inputBuilderFactory() .createConfiguratorInputBuilder('userInput') .buildContextParameter() ] return formFieldSet
api.inputBuilderFactory() .createConfiguratorInputBuilder('userInput', configuratorLogicName, true) .getInput()
processor.addOrUpdateInput( //❶ 'ROOT', api.inputBuilderFactory() .createConfiguratorInputBuilder('userInput') .buildMap() )

❶ the processor can be one of the quoteProcessor, cProcessor, etc., which references subclasses of the CalculableLineItemCollectionBuilder

You need to give each form an input name. The inputs from that form will be accessible via that name on the input binding variable:

Form Field Sets (ConfiguratorEntry)

A form field set (ConfiguratorEntry) is a container for inputs that share the same purpose. A field set can be accompanied by a legend that describes the purpose of the field set.

single field set
Figure 1. A screen capture of a form field set with one legend and two inputs.

The configurator logic is executed each time the end user provides an input. This means that the input fields will be recreated on each execution. Therefore, to persist the value that the user just provided, you must explicitly set the value of the newly generated input field.

❶ Create the two inputs that the form field set will contain.
❷ Set the value of the input field to the value that the user had already provided (if any).

An element of a form logic (Configurator) that returns a form field set (ConfiguratorEntry)

Form Field Set Arrays (ConfiguratorEntryArray)

A field set array is a container for multiple form field sets.

Create a form field set array by providing the form field sets to api.createConfiguratorEntryArray():

Where timeFieldSet and countryFieldSet are instances of ConfiguratorEntry:

Interactive Forms

Forms can be made interactive, meaning they can change appearance according to the input provided by the end user.

In the example below, the country input is not made visible until the end user chooses a region first. If the user changes the region, the country input is cleared.

Example Configuration Inputs Groovy.

Form Dialogs

A form can either be embedded, or it can be made to appear in a dialog. To open the dialog, the user will have to click a button.

❶ Open the form as a dialog, rather than embedding it.

Styles Legends

Legends can be styled, by providing the message as an HTML string with inline styling:

Be very restrained with inline styling, as this may clash with the frontend application’s style sheets. Even if it looks good at the moment, the frontend application styling might change in the future.

❶ The legend is wrapped within a code element and styled with bold.

Images

By setting the legend to an HTML img element, you can display an image inside a form:

Example Configuration Image Groovy

 

Found an issue in documentation? Write to us.