Skip to main content

Form for Defined Values

The Form widget allows you to filter and input data in your data app. By defining one or more Python variables or static values, you can render an interactive form for user input.

If you want to filter a data source (tabular data), consider using the Form for Data Sources.

This is an example of a form:

Widget Form

Basic usage

The first thing you need to do is configure the output variable name (prefixed with $), such as $out. By default, every form comes configured with an output variable that will store all the selected values. You can change the name if you prefer.

Next, you need to add Elements, which are the main building blocks of the form. To add elements, go to the Elements section and start adding the selectors you want to include in the form. For each element, specify the Element Name, Type, and the Selector you want to use.

  • Name: Defines the name of the element. This name should be unique within the entire data app, as it will be used as a global parameter.
  • Type: Defines the data type of the element (e.g., String, Number, Boolean).
  • Selector: Defines the type of selector used from a predefined list (e.g., Dropdown, Checkbox).

Some types of selectors, such as dropdowns, will require you to define Options. You can specify these options in the box by separating them with commas or by binding a Python variable (prefixed with $) containing your options.

After you have filled in all the required fields, you can click the Submit button to save the output to the selected variable. You can then use this output in your Python code or display it in a table, chart, or KPI widget.

info

By default, all selectors are included in the form as required fields. This means that the execution of the notebook will stop until all required fields are filled.

If you do not want the execution to stop, you can either have no required fields or set default values for all required fields.

Retrieving selected values

Each time the form is submitted, the selected values are stored in the context as Python variables.

The Output Variable will be stored in the Python context as a dictionary containing the selected values.

In addition to this dictionary, one variable per element is created with the structure of the Output Variable followed by the Name of each selector. For example, a widget with an output variable named out1 and a selector named name will add a variable named out1_name to your context.

Dependencies

If you want to add dependencies between selectors, you have three options:

  1. Change Their Options: If a variable used in the Options of a selector is changed in another block, the selector will be reinitialized to its default value.

  2. Reset on Selector Change: Use the field called Reset on Selector Change to indicate the names of one or more elements from other selectors (separated by commas) that, when changed, will reset the current selector to its default value.

  3. Bind a Variable: You can bind a variable to the element. This binding works both ways: every time the variable is modified, the element will update, and vice versa.

Supported form selectors

Widgets that allow users to select options from a list by clicking on a drop-down menu.

  • Dropdown
  • Multiple Dropdown

Boolean

Interactive elements for choosing between two options, typically representing true or false states.

  • Checkbox
  • Switch

Dates

Widgets for selecting dates or date ranges for various purposes, such as filtering data or setting appointments.

  • Date Selector
  • Date Range
  • Date and Time Range
  • Month Range
  • Year Range

Text

Input fields for users to enter text data.

  • Text Field: For single-line entries.
  • Text Area: For multi-line entries.

Sliders

Interface elements that allow users to select a value or a range within a specified range by moving a slider handle.

  • Number Slider
  • Range Slider

Radio

Widgets for selecting a single option from a list or multiple options from a list, typically presented as radio buttons or checkboxes.

  • Radio Button
  • Radio Button Group
  • Multiple Checkboxes

Setting initial values from URL parameters

You can pre-fill form elements by binding them to variables initialized from URL query parameters. This allows sharing links with pre-configured forms (e.g., ?category=Electronics&date_range=2023-01-01_2023-12-31).

Implementation steps

  1. Capture URL Parameters in Early Block: In a Python block before your form widget, initialize variables using MINEO_SELECTORS:

    # Capture URL parameters with fallback defaults
    initial_category = MINEO_SELECTORS.get('category', 'All')
    initial_date_range = MINEO_SELECTORS.get('date_range', '2023-01-01_2023-12-31')
  2. Then use any of those variables as Variable binding in your widget.

API reference

Basic

Setting NameTypeDescriptionDefault
Output VariablestringThe variable to store the output (prefixed with $).

Elements

Configuration for each element added to the form.

Basic

Setting NameTypeDescriptionDefault
NamestringThe identifier name for the element. This should be unique within the data app.
TypeenumThe data type of the element (String, Number, Boolean, etc.).String
SelectorenumThe type of selector to use (e.g., Dropdown, Checkbox).
OptionsComma-separated values or Python variableOptions for dropdowns or selection inputs. You can enter values separated by commas or bind a Python variable containing a list of values (prefixed with $).
LabelstringThe label to display in the form.<Name>
Help TextstringHelp text displayed in the selector before selecting any value.
RequiredbooleanWhether the input is required in the form.true
OrderNo order | Ascending | DescendingData sorting for the options.No order
Default ValuestringThe default value for the input.
Reset on Selector ChangestringNames of other selectors (separated by commas) that, when changed, will reset the current selector to its default value.
Variable BindingPython variableThe Python variable to bind to this element (two-way binding).

Layout

Setting NameTypeDescriptionDefault
SpannumberNumber of grid cells for this item (1–24).6
OffsetnumberNumber of grid cells to offset this item (0–24).0

Format

Setting NameTypeDescriptionDefault
SuffixstringThe suffix for the value.
Numeral FormatstringThe format to use for the value. See Numeral.js for more information.

Style

Customize the typography of the selector.

Setting NameTypeDescriptionDefault
Label StyleobjectStyle settings for the label.
Value StyleobjectStyle settings for the input value.

Format

Format options for the form.

General

Setting NameTypeDescriptionDefault
Horizontal GutternumberHorizontal space between form elements, in pixels (848).24
Vertical GutternumberVertical space between form elements, in pixels (848).24
SizeenumSize of the elements (Small, Middle, Large).Middle
AlignmentenumVertical alignment of the form (Top, Middle, Bottom).Middle
Title LayoutenumLayout for the title (label) of each input (Top, Inline).Top
General SpannumberDefault grid cells for each item (1–24).6
General OffsetnumberDefault grid offset for each item (0–24).0
Label StyleobjectStyle settings for all labels.
Value StyleobjectStyle settings for all values.

Buttons

Setting NameTypeDescriptionDefault
Submit ModeenumMode to submit the form (Submit Button, Submit on Change).Submit Button
Submit Button LabelstringThe label for the submit button.Submit
Show Reset ButtonbooleanWhether to display a button to reset the form.false
Reset Button LabelstringThe label for the reset button.
AlignenumAlignment for the buttons (Start, End, Center).Start
SpannumberGrid cells for the buttons (1–24).6
OffsetnumberGrid offset for the buttons (0–24).0

See also