SpinForms class to create form elements like checkboxes, text boxes, dropdowns, and connection selectors.

When to Use Form Cells
Use form cells when input values will be used by subsequent cells. Form cells create reusable inputs that later cells can reference. This is ideal for notebooks where users configure settings upfront (e.g., selecting an environment, entering a service name) that affect multiple downstream operations. Use @param syntax in Python cells when you need to parameterize a single cell’s behavior. The @param values are scoped to that one cell and are best for cell-specific configuration that doesn’t need to be shared.Important Notes
- Re-execution: Form cells automatically re-run when a session starts, when any cell before the form finishes running, or when the user interacts with any form input.
-
Performance: Because form cells re-run frequently, avoid expensive operations like API calls or database queries directly in form cells. Instead, perform data fetching in Python cells before the form cell and reference the results using
CellResult.get_from_cell(). -
Variable naming: The form input
idshould be a valid Python variable name and should match the variable you assign the return value to. -
Form-only usage: SpinForms functions can only be used in form cells, not in regular Python cells. Use the
@paramsyntax for Python cell parameters.
Available Input Types
Checkbox
Returns a boolean value.Textbox
Returns a string value.Dropdown
Returns the selected string value.Static Options
Provide a list of strings for simple dropdown options:Options with Display Labels
Use a dictionary to show different labels than the underlying values:Dynamic Options from Previous Cells
Populate dropdown options from the output of a previous cell: Initial shell cell (id=get_context_list) to get a list of kubectl context names, delimited by newlineMulti-Select Dropdown
Enable multiple selections by settingmulti=True. Returns a list of selected values instead of a single string.
Connections
Returns the selected connection name. Useful for letting users select from configured integrations.Secrets
Returns the selected secret name. Use this when you want users to choose which credential to use at runtime.Using the Selected Secret in Subsequent Cells
Since the secrets form returns the name of the secret (not the value), use{{secret_var:variable_name}} in non-Python cells to retrieve the actual secret value:
Form Cell:
Use
{{secret:SECRET_NAME}} when the secret name is static. Use {{secret_var:variable_name}} when the secret name is stored in a variable (e.g., from a form dropdown).Time Range
Returns a tuple of two Pythondatetime objects representing the earliest and latest times in the range.
Time Expression Syntax
The time range picker supports various time expressions:Using Time Range Values
The returned datetime objects can be used directly with time-based APIs:Validation
Validate form inputs by raisingSpinForms.ValidationError. The error message will be displayed next to the corresponding form input.
Conditional Validation
Using Form Values in Subsequent Cells
Form cell variables are available to all subsequent cells in the notebook.In Python Cells
Reference form variables directly by their ID:In Non-Python Cells
Use the{{variable_name}} template syntax to reference form values in REST cells, LLM cells, Shell cells, and integration cells:
REST Cell: