createFormView
Signature
Section titled “Signature”const view = createFormView(options);CreateFormViewOptions is the same family of app-facing inputs used by mountForm(), plus headless layout.
Input options
Section titled “Input options”Required:
schematransport
Common optional inputs:
layoutregistryprimitiveRegistrydesignSystemRegistryinitialValuesvalidatorshooksinactiveFieldPolicylistenerErrorPolicyonListenerError
Returned controller
Section titled “Returned controller”interface FormViewController { form: FormController; engineRegistry: Registry; primitiveRegistry: PrimitiveRegistry; designSystemRegistry: DesignSystemRegistry; state: FormViewState; getSnapshot(): FormViewSnapshot; getNodeById(id: string): ResolvedFormLayoutNode | undefined; getField(id: string): FormViewFieldItem | undefined; getReport(id: string): FormViewReportItem | undefined; getExplanation(id: string): FormViewExplanationItem | undefined; getVisibleFields(): FormViewFieldItem[]; getVisibleReports(): FormViewReportItem[]; getVisibleExplanations(): FormViewExplanationItem[]; 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:
formlayoutfieldsreportsexplanationswizardtabsaccordion
wizard is null unless layout.kind === "wizard".
tabs is null unless layout.kind === "tabs".
accordion is null unless layout.kind === "accordion".
Item collections
Section titled “Item collections”Each field item contains:
idkindconfigcontrollerstatedescriptorstepIdtabIdvisibleInLayout
The report and explanation collections follow 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
Accordion controls
Section titled “Accordion controls”toggleSection(sectionId)opens or closes one accordion sectionopenSection(sectionId)andcloseSection(sectionId)are explicit variantsopenAllSections()andcloseAllSections()manage the full accordion state- all accordion control methods throw outside
layout.kind === "accordion"
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 attach stylesheets or mutate DOM. Use:
mountForm()for built-in one-page DOMmountWizardForm()for built-in wizard DOMmountTabsForm()for built-in tabs DOMmountAccordionForm()for built-in accordion DOMattachDesignSystem()yourself when your custom host needs it