mountForm
mountForm(container, options) creates the engine form, mounts primitive Web Components, attaches the design system, and returns a mounted handle.
import { mountForm } from "mlform/kit";import { createJsonTransport } from "mlform/transport";
const mounted = mountForm(container, { transport: createJsonTransport({ endpoint: "/api/predict" }), schema, initialValues: { age: 42 }, labels: { submit: "Predict" }, layout: "split", reportPane: "auto", reportFetchMode: "all",});The returned object exposes:
| Property or method | Use |
|---|---|
form | Access the FormController. |
host | Access the mounted Web Component host. |
updateDesignSystem(config) | Merge design system changes. |
replaceDesignSystem(snapshot) | Replace with an explicit mode, theme, and recipe. |
resetDesignSystem() | Restore defaults. |
unmount() | Abort pending submit, disconnect styling, and remove the host. |
Notes:
- Calling
mountFormagain on the same container automatically unmounts the previous MLForm instance first. mountFormexpects an empty container by default.- Pass
containerStrategy: "replace"only when you want MLForm to replace existing host content and restore it onunmount(). reportFetchModecontrols async reports after submit:"lazy"keeps renderer-driven fetches,"all"waits for all fetch-backed reports before success events, and"none"skips report fetches.