form() (alias form_action()) wraps input components and submits their values to your @aiui.page_action handler—either on button submit or live with submit_on_change=True.
form()
form_action()
@aiui.page_action
submit_on_change=True
<ComponentPreview title="Interactive Form (click Save)">
{
"type": "form_action",
"action": "save_agent",
"submit_label": "Save Agent",
"children": [
{"type": "text_input", "label": "Agent Name", "value": "Researcher", "name": "name"},
{"type": "select_input", "label": "Model", "options": ["gpt-4o", "gpt-4o-mini", "claude-3.7-sonnet"], "value": "gpt-4o", "name": "model"},
{"type": "switch_input", "label": "Enable memory", "checked": true, "name": "memory"}
]
}
</ComponentPreview>
<Tabs>
<Tab title="Python">
</Tab>
<Tab title="YAML">
</Tabs>
| Parameter | Type | Description |
|---|---|---|
| action, children | str, list | Server action name and list of input components. |
action
children
str
list
| submit_label | str | Submit button text (default "Submit"). |
submit_label
"Submit"
| actions | list[dict] \| None | Optional named action buttons ({"id", "label", "variant", "disabled", "submit"}). Each button submits all collected form values plus action: id. |
actions
list[dict] \| None
{"id", "label", "variant", "disabled", "submit"}
action: id
| baseline_key | str \| None | Optional revision key; changing it resets the clean/dirty baseline reported to <BlockTree onFormState={...} />. |
baseline_key
str \| None
<BlockTree onFormState={...} />
| method, update_url, submit_on_change | options | Use method="get" to sync filters to URL query params, or submit_on_change=True for instant updates. |
method
update_url
submit_on_change
method="get"
Use actions for multi-button workflows (such as Save draft, Preview, and Publish), and pass onFormState on <BlockTree> to track { action, values, dirty, busy, pendingAction } without DOM event hacks:
onFormState
<BlockTree>
{ action, values, dirty, busy, pendingAction }
Structured controls such as rich_text_input(), multiselect_input(), and tags_input() participate in the exact same onFormState, baseline_key, and named-action contract and post their structured JSON values directly.
rich_text_input()
multiselect_input()
tags_input()