createFormView
Signature
Section titled “Signature”const view = createFormView(options);CreateFormViewOptions is the headless state/layout input surface. Mounted UI concerns such as primitive and design registries stay on mountForm() and the built-in shell mounts.
Input options
Section titled “Input options”Required:
schematransport
Common optional inputs:
layoutregistryinitialValuesvalidatorshooksinactiveFieldPolicylistenerErrorPolicyonListenerError
Returned controller
Section titled “Returned controller”interface FormViewController { form: FormController; engineRegistry: Registry; descriptorRegistry: PrimitiveDescriptorRegistry; state: FormViewState; getSnapshot(): FormViewSnapshot; getNodeById(id: string): ResolvedFormLayoutNode | undefined; getField(id: string): FormViewFieldItem | undefined; getReport(id: string): FormViewReportItem | undefined; getVisibleFields(): FormViewFieldItem[]; getVisibleReports(): FormViewReportItem[]; getActiveLayoutNodes(): ResolvedFormLayoutNode[]; validate(): Promise<FormValidationResult>; submit(options?: SubmitOptions): Promise<SubmitResult>; reset(): void; subscribe(listener): () => void; nextStep(): Promise<boolean>; prevStep(): void; goToStep(stepId: string): Promise<boolean>; setActiveTab(tabId: string): void; nextTab(): boolean; prevTab(): boolean; toggleSection(sectionId: string): void; openSection(sectionId: string): void; closeSection(sectionId: string): void; openAllSections(): void; closeAllSections(): void;}Snapshot shape
Section titled “Snapshot shape”getSnapshot() returns:
formlayoutfieldsreportswizardtabsdisclosure
wizard is null unless layout.kind === "wizard".
tabs is null unless layout.kind === "tabs".
disclosure is null unless layout.kind === "disclosure".
Item collections
Section titled “Item collections”Each field item contains:
idkindconfigcontrollerstatedescriptorstepIdtabIdvisibleInLayout
The report collection follows the same pattern.
Navigation semantics
Section titled “Navigation semantics”nextStep()
Section titled “nextStep()”- only meaningful for wizard layouts
- validates fields in the current step
- returns
falseon validation failure - returns
truewhen the current step is valid - does not advance past the last step
prevStep()
Section titled “prevStep()”- only meaningful for wizard layouts
- never validates
- moves back one step when possible
goToStep(stepId)
Section titled “goToStep(stepId)”- allows free backward navigation
- validates incrementally when moving forward
- throws if used outside a wizard layout
setActiveTab(tabId)
Section titled “setActiveTab(tabId)”- only meaningful for tabs layouts
- switches tabs without validation
- throws if used outside a tabs layout
nextTab() / prevTab()
Section titled “nextTab() / prevTab()”- only meaningful for tabs layouts
- never validate
- return
falsewhen movement is not possible
Disclosure controls
Section titled “Disclosure controls”toggleSection(sectionId)opens or closes one disclosure sectionopenSection(sectionId)andcloseSection(sectionId)are explicit variantsopenAllSections()andcloseAllSections()manage the full disclosure state- all disclosure control methods throw outside
layout.kind === "disclosure"
Subscription model
Section titled “Subscription model”Use subscribe() for host rendering:
const unsubscribe = view.subscribe((snapshot) => { render(snapshot);});Typical host pattern:
- create the view once
- render initial snapshot
- subscribe
- on teardown, unsubscribe and abort or unmount host-side resources
Design system note
Section titled “Design system note”createFormView() does not resolve primitive renderers, attach stylesheets, or mutate DOM. Use:
mountForm()for built-in one-page DOMmountForm()for built-in wizard DOMmountForm()for built-in tabs DOMmountForm()for built-in disclosure DOMattachDesignSystem()yourself when your custom host needs it