WHAT YOU'LL LEARN
  • How to create forms using the FormModel API?
  • What field types are available and how to configure them?
  • How to arrange fields with the layout builder?
  • How to add validation, conditional visibility, and computed fields?
  • What built-in renderers are available?
  • How to create custom field renderers?
USAGE EXAMPLES

See Page Settings for end-to-end usage examples.

Overview
anchor

The Form Model is Webiny’s declarative form system for the admin UI. It provides a fluent builder API for defining fields, arranging them with a layout builder, validating with Zod schemas or imperative rules, and rendering with React. Fields support conditional visibility, computed values, and deeply nested object structures with dynamic zones.

The typical workflow is: define fields via form.fields(), arrange them with form.setLayout(), and render with the <FormView> component. For extending existing forms (e.g., page settings), use form.fields() and form.layout() to add new fields and layout nodes to an existing form model.

FormModel
anchor

field
anchor

Gets a single field instance by name. Supports dot-notation paths for nested object fields.

Signature:

Parameters:

ParameterTypeRequiredDescription
namestringYesField name, or dot-notation path (e.g. "address.city")

getField
anchor

Gets a field instance by name, returning undefined if the field does not exist.

Signature:

Parameters:

ParameterTypeRequiredDescription
namestringYesField name

fields
anchor

Defines or adds fields to the form model. Can be called multiple times to extend an existing form.

Signature:

Parameters:

ParameterTypeRequiredDescription
factoryfunctionYesCallback receiving the field builder registry, returns a record of named field builders

removeField
anchor

Removes a field from the form model.

Signature:

Parameters:

ParameterTypeRequiredDescription
namestringYesName of the field to remove

layout
anchor

Modifies the existing layout by adding, removing, or repositioning layout nodes.

Signature:

Parameters:

ParameterTypeRequiredDescription
factoryfunctionYesCallback receiving the layout modifier, returns an array of layout nodes

Overload — access a layout node by ID:

ParameterTypeRequiredDescription
nodeIdstringYesID of the layout node to access

setLayout
anchor

Sets the initial form layout. Use this when defining a form from scratch.

Signature:

Parameters:

ParameterTypeRequiredDescription
factoryfunctionYesCallback receiving the layout builder, returns an array of builders

getData
anchor

Returns all form data as a plain object.

Signature:

This method takes no parameters.


setData
anchor

Sets the form data, populating all field values.

Signature:

Parameters:

ParameterTypeRequiredDescription
dataRecord<string, unknown>YesThe form data object

validate
anchor

Validates all fields and form-level rules. Returns true if the form is valid.

Signature:

This method takes no parameters.


submit
anchor

Validates the form and returns the form data if valid, or false if validation fails.

Signature:

This method takes no parameters.


addRule
anchor

Adds a cross-field validation rule. Accepts a Zod schema or an imperative validation function.

Signature:

Parameters:

ParameterTypeRequiredDescription
ruleFormRuleYesA z.ZodTypeAny schema or a (form) => IFormError[] function

reset
anchor

Resets the form to its initial state, clearing all dirty flags and validation results.

Signature:

This method takes no parameters.


focusField
anchor

Focuses a specific field, automatically activating any tabs needed to make it visible.

Signature:

Parameters:

ParameterTypeRequiredDescription
namestringYesName of the field to focus

Properties
anchor

PropertyTypeDescription
isDirtybooleanWhether any field value has changed
isValidboolean \| nullValidation result, null if not yet validated
submittedbooleanWhether the form has been submitted
errorsIFormError[]Array of { path, label?, message } objects
vmIFormVMView model for rendering

Field Types
anchor

All fields are created via the fields registry callback passed to form.fields(). Each factory method returns a chainable field builder.

text
anchor

Creates a text field. Value: string | null. Default renderer: textInput.

Signature:


number
anchor

Creates a number field. Value: number | null. Default renderer: numberInput. Automatically normalizes string input to numbers.

Signature:


boolean
anchor

Creates a boolean field. Value: boolean | null. Default renderer: switch.

Signature:


datetime
anchor

Creates a date/time field. Default renderer: dateTimeInput. Call a variant method to set the subtype:

VariantValue FormatDescription
.dateOnly()"2026-05-01"Calendar date only
.timeOnly()"14:30:00"Time only
.withTimezone()"2026-05-01T14:30:00+02:00"Date+time with offset
.withoutTimezone()"2026-05-01T14:30:00.000Z"Date+time in UTC
.monthOnly()"2026-05"Month picker
.weekOnly(options?)"2026-W18"Week picker
.yearOnly(options?)2026Year picker
.dateRange(){ from, to }Date range picker
.multipleDates()string[]Multiple dates
.multipleMonths()string[]Multiple months
.multipleYears(options?)number[]Multiple years

Additional chainable methods:

MethodDescription
.presets([...])Quick-select preset buttons with label and value function
.displayFormat(format)Custom display format using date-fns tokens

Signature:


file
anchor

Creates a file field. Value: FileValue | null (object with id, name, size, mimeType, src, width, height). Default renderer: filePicker.

Signature:


fileUrl
anchor

Creates a file URL field. Value: string | null (URL only). Default renderer: fileUrlPicker.

Signature:


object
anchor

Creates an object field for nested structures, lists, and dynamic zones. Value: Record<string, unknown> | null. Default renderer: objectAccordionSingle.

Signature:

See Object Fields for the full object-specific API.


Field Builder Methods
anchor

These chainable methods are available on all field builders returned by the field type factories.

label
anchor

Sets the field label.

Signature:


description
anchor

Sets the description text displayed below the field.

Signature:


help
anchor

Sets the help text.

Signature:


note
anchor

Sets a supplementary note.

Signature:


placeholder
anchor

Sets the input placeholder text.

Signature:


defaultValue
anchor

Sets the default value. Can be a static value or a function for dynamic defaults.

Signature:


required
anchor

Marks the field as required.

Signature:

Parameters:

ParameterTypeRequiredDescription
messagestringNoCustom validation error message

requiredWhen
anchor

Conditionally marks the field as required based on other field values.

Signature:

Parameters:

ParameterTypeRequiredDescription
fnfunctionYesPredicate receiving the form model
messagestringNoCustom validation error message

schema
anchor

Sets a Zod validation schema for the field.

Signature:

Parameters:

ParameterTypeRequiredDescription
zodSchemaz.ZodTypeAnyYesZod schema object

renderer
anchor

Overrides the default renderer for the field.

Signature:

Parameters:

ParameterTypeRequiredDescription
namestringYesRenderer name
settingsRecord<string, unknown>NoRenderer-specific settings

options
anchor

Adds value options. Automatically switches text/number fields to the dropdown renderer.

Signature:

Parameters:

ParameterTypeRequiredDescription
optsIValueOption[] \| functionYesStatic array or function returning options dynamically

Each IValueOption has: { label: string, value: string | number, disabled?: boolean }.


list
anchor

Converts the field to an array field. Automatically switches renderers (e.g., textInput to textInputs, objectAccordionSingle to objectAccordionMultiple).

Signature:


hidden
anchor

Hides the field from the UI. The value remains in the form data.

Signature:


disabled
anchor

Disables the field.

Signature:


rules
anchor

Sets conditional visibility and disable rules for the field. See Conditional Rules.

Signature:


computed
anchor

Makes the field always computed — its value is recalculated whenever dependencies change.

Signature:


computedUntilDirty
anchor

Makes the field computed until the user manually edits it.

Signature:


beforeChange
anchor

Adds a transform that runs before a value change is applied. Return the transformed value.

Signature:


afterChange
anchor

Adds a callback that runs after a value change is applied.

Signature:


afterSetValue
anchor

Adds a callback that runs after a programmatic setValue() call.

Signature:


onBlur
anchor

Adds a callback that runs when the field loses focus.

Signature:


cloneValue
anchor

Sets custom clone logic for when a list item containing this field is duplicated.

Signature:


tags
anchor

Tags the field for programmatic lookup.

Signature:


Field Instance
anchor

The IField interface represents a runtime field instance, returned by form.field("name").

getValue
anchor

Gets the current field value.

Signature:


setValue
anchor

Sets the field value, triggering beforeChange and afterChange callbacks.

Signature:


setValueSilent
anchor

Sets the field value without triggering callbacks.

Signature:


as
anchor

Casts the field to a typed field interface.

Signature:

Parameters:

ParameterTypeRequiredDescription
typestringYesField type to cast to (e.g. "object", "text")

validate
anchor

Validates the field against its schema, required status, and rules.

Signature:


blur
anchor

Triggers the blur event on the field.

Signature:


focus
anchor

Requests focus on the field.

Signature:


remove
anchor

Removes the field from the form model.

Signature:


setDisabled
anchor

Sets the disabled state of the field.

Signature:


setVisible
anchor

Sets the visibility of the field.

Signature:


Properties
anchor

PropertyTypeDescription
namestringField name
typestringField type (e.g. "text", "number")
visiblebooleanWhether the field is visible
disabledbooleanWhether the field is disabled
qualifiedNamestringFull dot-notation path for nested fields
isComputedbooleanWhether the field is computed
vmIFieldVMView model for rendering

Object Fields
anchor

Object fields support nested structures, lists, and dynamic zones (templates). Access via form.field("name").as("object") or use the ObjectFieldBuilder.

Builder Methods
anchor

fields
anchor

Defines child fields for the object.

Signature:


template
anchor

Defines a dynamic zone template. Calling .template() automatically switches the renderer to dynamicZone.

Signature:

The ITemplateBuilder supports:

MethodDescription
.label(text)Template display name
.icon(icon)Template icon
.fields(fn)Define template fields
.visible(predicate)Conditional template visibility

listSchema
anchor

Adds a Zod validation schema for the list as a whole.

Signature:


Runtime Methods
anchor

These methods are available on IObjectField, accessed via form.field("name").as("object").

addItem
anchor

Adds a new item to a list object field. For templated fields, pass a template ID.

Signature:


removeItem
anchor

Removes an item from a list object field by index.

Signature:


moveItem
anchor

Moves an item within a list object field.

Signature:


duplicateItem
anchor

Duplicates an item in a list object field.

Signature:


setTemplate
anchor

Sets the active template on a single-value templated object field.

Signature:


Runtime Template Management
anchor

Templates can be added or removed at runtime via the templates property:


Properties
anchor

PropertyTypeDescription
isListbooleanWhether this is a list object field
isTemplatedbooleanWhether templates are defined
activeTemplateIdstring \| nullCurrently selected template ID
availableTemplatesITemplateVM[]Available templates
childrenMap<string, IField>Child fields (for single objects)
itemsIListItemField[]List items (for list objects)

Layout Builder
anchor

The layout builder controls how fields are arranged in the UI. Use form.setLayout() for initial layout definition, or form.layout() to modify an existing layout.

row
anchor

Arranges one or more fields in a horizontal row.

Signature:


separator
anchor

Adds a visual divider between layout sections.

Signature:


tabs
anchor

Creates a tabbed layout container.

Signature:

The ITabsBuilder supports chaining:

MethodDescription
.renderer(name)Set tab renderer (e.g. "tabsVertical")
.tab(id, configure)Add a tab
.rules(rules)Conditional visibility rules for the tab group

The tab configure callback receives an ITabBuilder:

MethodDescription
.label(text)Tab label
.description(text)Tab description
.icon(icon)Tab icon
.layout(fn)Tab content layout
.rules(rules)Tab-level visibility rules

element
anchor

Adds a custom rendered element to the layout.

Signature:


object
anchor

Defines the inner layout for an object field.

Signature:

Overload — per-template layouts for dynamic zones:


Positioning
anchor

When modifying an existing layout, use .after() or .before() to position relative to existing fields:

The .replace(target) method removes the target and inserts the new node in its place.


Conditional Rules
anchor

Rules control field visibility and disabled state based on other field values. Pass them via the .rules() builder method.

Rule structure:

PropertyTypeDescription
typestringRule type (use "condition")
targetstringField name to watch
operatorstringComparison operator (see below)
valuestring \| nullComparison value (null for unary operators)
actionstring"hide" or "disable"

Operators
anchor

OperatorDescription
"eq"Equal to value
"neq"Not equal to value
"isEmpty"Null, undefined, empty string, or empty array
"isNotEmpty"Has a non-empty value
"isTruthy"Boolean coercion is true
"isFalsy"Boolean coercion is false
"matches"Exact string match

Built-in Renderers
anchor

RendererField TypeSettingsDescription
textInputtextSingle-line text input
textareatext{ rows?: number }Multi-line text area
textInputstext (list){ addItemLabel?: string }List of text inputs
textareastext (list){ addItemLabel?: string }List of textareas
tagstext (list)Comma-separated tag input
codeEditortext{ language?: string, height?: number }Code editor with syntax highlighting
dropdowntext, numberSelect dropdown (auto when .options())
radioButtonstext, numberRadio button group
checkboxestext (list), number (list)Checkbox group
numberInputnumberNumber input
numberInputsnumber (list){ addItemLabel?: string }List of number inputs
switchbooleanToggle switch
dateTimeInputdatetime{ type, displayFormat?, yearRange?, weekStartsOn?, presets? }Date/time picker
dateTimeInputsdatetime (list){ type, displayFormat?, weekStartsOn?, addItemLabel? }List of date/time pickers
filePickerfileFile picker with full metadata
fileUrlPickerfileUrlFile picker returning URL only
objectAccordionSingleobject{ open?: boolean }Single object in accordion
objectAccordionMultipleobject (list){ open?, container?, itemTitle?, addItemLabel? }List of objects in accordions
dynamicZoneobject (templates){ container?: boolean }Template picker zone
passthroughobjectRenders child fields inline
keyValueTagsobject (list){ addItemLabel?: string }Key-value tag pairs
hiddenanyHidden field (no UI rendered)

Automatic Renderer Switching
anchor

  • Calling .options() on text/number fields switches to dropdown
  • Calling .list() on datetime switches to dateTimeInputs
  • Calling .list() on object switches to objectAccordionMultiple
  • Calling .template() on object switches to dynamicZone

Custom Renderers
anchor

createFieldRenderer
anchor

Creates a custom field renderer component.

Signature:


createObjectFieldRenderer
anchor

Creates a custom renderer for object fields.

Signature:


FormView
anchor

The FormView component renders a form model in the UI.

Signature:

Props:

PropTypeRequiredDescription
formIFormVMYesThe form view model
renderersFieldRenderersNoCustom field renderer overrides
layoutRenderersLayoutRenderersNoCustom layout renderer overrides