Conditional inputs

Input conditional dependent on other input results. To use it, the name of the parent input has to be included as the parameter 'dependsOn' of the child, like so:

report_dataset_properties = {
    'fields': [{
            'title': 'Conditional input form',
            'fields': [
                {
                    'mapping': 'country',
                    'fieldName': 'Country',
                    'inputType': 'select',
                    'options': ['España', 'Colombia']
                },
                {
                    'dependsOn': 'Country',
                    'mapping': 'city',
                    'fieldName': 'City',
                    'inputType': 'select',
                    'options': {
                        'España': ['Madrid', 'Barcelona'],
                        'Colombia': ['Bogotá', 'Medellin']
                    }
                }
            ]
        }
    ]
}

s.plt.input_form(
    order=0, options=input_data
)

When the input has the parameter 'dependsOn', it has to define a set of options for every option in the parent input. In the case shown above the parent input has the options: 'España', 'Colombia', so the child input defines the list ['Madrid', 'Barcelona'] for 'España' and ['Bogotá', 'Medellin'] for 'Colombia'. The result is:

Resulting options in child when selecting 'España' in the parent input
Resulting options in child when selecting 'Colombia' in the parent input

Last updated

Was this helpful?