createFormView
Signature
Section titled “Signature”const view = createFormView(options);Import createFormView from mlform/view. It composes runtime state, layout, navigation, and
presenter descriptors without mounting DOM. Primitive renderer and design system options stay on
mountForm().
Input options
Section titled “Input options”Required:
schematransport
Common optional inputs:
layoutpluginsregistryinitialValuesvalidatorshooksinactiveFieldPolicylistenerErrorPolicyonListenerError
Use plugins for custom field and report kinds. A plugin carries its schema definition, presenter, and optional runtime behaviors through one interface; direct registry options remain available for low-level integrations.
Returned controller
Section titled “Returned controller”interface FormViewController { form: FormController; reportFetchMode: ReportFetchMode; engineRegistry: Registry; descriptorRegistry: PrimitiveDescriptorRegistry; navigation: FormViewNavigationController; state: FormViewState; getSnapshot(): FormViewSnapshot; getNodeById(id: string): ResolvedFormLayoutNode | undefined; getField(id: string): FormViewFieldItem | undefined; getReport(id: string): FormViewReportItem | undefined; getVisibleFields(): FormViewFieldItem[]; getVisibleReports(): FormViewReportItem[]; validate(): Promise<FormValidationResult>; submit(options?: SubmitOptions): Promise<SubmitResult>; submitPipeline(options?: SubmitOptions): Promise<PipelineResult>; reset(): void; dispose(): void; subscribe(listener): () => 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 when the active layout contains no disclosure sections.
Item collections
Section titled “Item collections”Each field item contains:
idkindconfigcontrollerstatedescriptorstepIdtabIdsectionId(the innermost section, if any)sectionIds(all enclosing sections, outermost first)visibleInLayout
The report collection follows the same pattern.
Navigation semantics
Section titled “Navigation semantics”navigation.next()
Section titled “navigation.next()”- in a wizard, validates the current step before advancing
- in tabs, advances without validation
- returns
falsewhen validation fails or movement is not available - a valid final wizard step returns
truewithout moving past the end
navigation.previous()
Section titled “navigation.previous()”- never validates
- moves back one wizard step or tab
- returns whether navigation changed
navigation.activate(id)
Section titled “navigation.activate(id)”- activates a tab directly
- allows free backward wizard navigation
- validates wizard steps incrementally when moving forward
- returns
falsefor stacked and split layouts - throws when the current wizard or tabs layout does not contain
id
navigation.getActiveNodes()
Section titled “navigation.getActiveNodes()”- returns the currently active layout nodes after wizard, tab, and disclosure state is applied
Disclosure controls
Section titled “Disclosure controls”navigation.disclosure.toggle(sectionId)opens or closes one sectionopen(sectionId)andclose(sectionId)are explicit variantsopenAll()andcloseAll()manage every section in the layout- section controls work inside stacked, split, wizard, and tabs layouts
- an unknown section id throws
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 call
view.dispose()
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 itcreatePrimitiveAdapter()frommlform/kitwhen your host owns the layout but uses built-in controls