Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 syntax check 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:

Expand
titleForms
Code Block
languagegroovy
themeMidnight
linenumbersfalse
def formFieldSet = api.createConfiguratorEntry()

formFieldSet.inputs = [
    api.inputBuilderFactory()
        .createConfiguratorInputBuilder('userInput')
        .buildContextParameter()
]

return formFieldSet
Expand
titleIn input generation mode (syntax check input generation mode)
Code Block
languagegroovy
themeMidnight
linenumbersfalse
api.inputBuilderFactory()
        .createConfiguratorInputBuilder('userInput', configuratorLogicName, true)
        .getInput()
Expand
titleIn header Logics
Code Block
languagegroovy
themeMidnight
linenumbersfalse
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:

Code Block
languagegroovy
themeMidnight
linenumbersfalse
input.userInput.nameOfInput as ValueType

...