Types of Nodes

Input nodes

Maps Domain Entity fields to form controls. Cannot contain sub-nodes.

Example:

    - input:
        field: field_name # required
        title: Field Name # default: field name
        enabled: true # default: true

        # meta - optional
        #        useful for user-defined behaviors
        meta:
            my_ref: important-input

        # none - optional
        #        used by widgets that have a "no value" state
        #        (e.g. choice type with a dropdown widget)
        none: Please select

        # Events
        # This function is called when the value changes and is successfully saved.
        onchange: |
            function(model, ctx, api) {
                log('Field "field_name" has changed');
            }

Group nodes

Depending on the traversal strategy a group node can indicate to Konfoo that the contained input nodes must be considered together.

All group nodes expect the structure under them to be a list of other nodes.

In version <= 0.4.0 the scene-graph only supports wizard and simple traversal strategies and thus only parallel group nodes are allowed.

A parallel group node signals Konfoo to ask input for all sub-nodes in one step.

Example:

    - parallel:
        - input:
            field: field1
            title: First Field
        - input:
            field: field2
            title: Second Field

Meta nodes

The purpose of meta nodes is to provide metadata key-value pairs to the immediate parent node. This exists to support user-defined behaviors.

The only exception is the title key which is used by Konfoo to display a user-friendly label for the node.

Example:

    - parallel:
        - meta:
            title: Size
        - input:
            field: width
            title: Width (mm)
        - input:
            field: height
            title: Height (mm)

Exec nodes

exec nodes allow you to execute code on the web client side. They are executed when they are encountered and that depends on the traversal strategy. This is useful for when you need to dynamically change something depending on the current state of the configuration.

Example:

    - parallel:
        - input:
            field: my_field
            title: My Field
        - exec:
            fn: |
                function(model, ctx, api) {
                    const root = api.getRef(ctx.root);
                    if (!root)
                        return;

                    log('Field value is:', root.fields.my_field);
                }

Model nodes

The model nodes cannot be defined by the form description language itself. Instead they are generated at the boundaries of domain entities: for instance one domain entity contains a list of another domain entity.