Ant Design Svelte

Form

Forms: typed model, rules, dependent fields, asynchronous validations and submission.

When to use

Form is needed when several fields form one task: registration, editing a record, searching or filling out an application. The model stores values ​​and errors, rules validate input, and dispatch receives a consistent set of data.

In @woodger/antd, create a model with Form.useForm() or createForm. Form connects the model to a native form, and Form.Item provides the field label, errors, and accessible description.

For one independent switch or filter, you can use the Svelte local state. Connect Form when you need general validation, sending and resetting of several fields.

Form CSS prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. Form and FormItem choose prefixes independently. FormList.prefixCls refers to the ErrorList, not the adjacent fields. Adaptive captions respect the screen*max design tokens of their topic area; changing the prefix preserves the model and rules.

Model and connection with fields

Call Form.useForm<Values>() during component initialization. The hook returns a one-element tuple and can reuse an existing model. Pass the model to Form with form. When form is omitted, the component creates its own model. initialValues provides defaults for fields that mount later as well.

Part of the form Responsibility Working example
createForm Meanings, Rules, Errors and Methods Model methods
Form Send, reset, design and context Regular form
FormItem Field name, label, error and tooltip Regular form
Control Input and change message Own control

form.values is available for reading and reactive computing. To record, use setFieldValue, setFieldsValue, or batch setFields. Do not assign properties to values directly or bind them through bind:value: the model must receive changes through its methods.

A named Form.Item supplies the label and field metadata to supported controls. Connect the value through the control snippet or pass it explicitly. To manage Input, InputNumber, or Select explicitly, pass value and call form.setFieldValue from onValueChange. For Switch and Checkbox, use checked and onCheckedChange. The checked field example shows the explicit connection.

The model stores scalars, nested objects, arrays, and instances of classes, including Dayjs. Objects and arrays are copied on set and reset; class instances are saved without serialization. The limits of the available API are listed in Form directory.

Layout and captions

Form.layout supports vertical, horizontal and inline; default Svelte - vertical. FormItem.layout can select vertical/horizontal separately. Field layout combines the general and local axis.

labelCol and wrapperCol use ColProps, including breakpoint maps. The field object replaces the generic entire, even if it is {}. Nested FormItems do not inherit the columns of the outer Item. labelAlign selects left/right, labelWrap enables wrapping. colon works for horizontal labels, and FormItem.colon:true takes precedence over Form.colon:false. Columns show individual settings and an action line with label:null.

label accepts text, number, array or snippet. null preserves the alignment offset; false, undefined and the empty string remove the signature without this offset. For a rich label, the component binds control via aria-labelledby; The control's own aria-label takes precedence. Do not put the second field inside the signature.

FormItem.tooltip accepts content or a Tooltip object with an icon-snippet. Form.tooltip and ConfigProvider.form.tooltip set defaults, but without the tooltip field the icon does not appear. Signatures and explanations use their own accessible icon button to open from the keyboard. The standard icon is not a separate Tab stop.

requiredMark only changes the design: true, false, optional or snippet with label and { required }. The check remains in rules. For optional, ConfigProvider.locale.Form.optional is localized; mandatory marks show options. If a label contains a snippet, the native renderer should render it via @render rather than converting it to a string.

Binding without its own wrapper

FormItem without name is a layout container: it does not create binding, native name and field rules. You can nest several named FormItems in it, as in composite field.

noStyle leaves pure binding without layout. Messages from named noStyle fields are collected by the nearest styled Item; help:false disables message passing. The visual status is inherited until its own metadata or validateStatus defines it. value/callback are still passed explicitly.

hidden saves DOM control, value and validation registration. This is different from uninstalling via Svelte if: with unmount, local rules are removed. Hidden field remains mandatory even without a visible block. The hidden/noStyle combination creates a hidden wrapper.

help is shown when there are no errors/warnings. extra stays close to them. Both areas accept rich content and participate in aria-describedby; reset recreates their contents along with the field. label, tooltip, help and extra are isolated from field binding: decorative control should not receive the name/id of the main field.

Visual status and metadata

Automatic status considers validating first, then errors, warnings and touched. With hasFeedback enabled, successful completed validation also produces success even when the field is not touched. validateStatus overrides the visual status; an empty string disables automatic status. It does not clear model messages: a real error still sets aria-invalid even with success or an empty visual status.

useFormItemStatus is called when a child component under the desired FormItem is initialized. The returned object contains readonly getter fields status/errors/warnings. Read item.status in markup or $derived: destructuring saves snapshot. Outside Item status is undefined; pristine Item has an empty string. Field status shows separate child readout and override change without losing errors.

hasFeedback adds an icon for the current status. Input controls, selection controls and date and time controls show the supported components. In these examples, validateStatus only controls appearance; the field status example demonstrates validation rules.

Form.feedbackIcons receives ({ status, errors, warnings }) and returns a map of icons by status. FormItem.hasFeedback={{ icons }} replaces the renderer for one field. A false map value hides the icon while retaining messages and validation. Values of null, undefined, '' and 0 use the default icon. Custom icons demonstrate form defaults, a local override and success after validating untouched fields.

A noStyle field inherits feedback from its parent field unless hasFeedback is explicitly set. A nested Form starts a new feedback context. InputOTP does not display these icons; Transfer receives the status and feedback class without a separate icon.

Nested names and updating values

NamePath is a string, number, or array of segments. The string profile.name denotes one literal key; the path ['profile', 'name'] accesses a field within the object. The numeric segment creates an array if there is no container yet; string '0' creates an object key. Example of nested paths shows separate values ​​for dot string and segment array.

getFieldValue(path) reads the path, setFieldValue(path, value) replaces its entire value. setFieldsValue recursively merges ordinary objects while preserving adjacent properties; arrays are replaced entirely. The “Update name only” button in the example saves the profile email.

For nested errors, use getFieldError(path) or getFieldsError(paths?). The FormValidationError.errorFields error also contains name segment arrays and errors messages. The errors model property shows only top-level errors. The native name of the control is collected via _; if necessary, pass the control your own name. To send the structure, use the values ​​from onFinish.

Dynamic and nested lists

FormList manages the array of the nearest Form and passes strings, operations and errors to snippet children(fields, operation, meta). Dynamic list shows adding to the end and beginning, deleting and moving. Each line contains the current index field.name and the stable index field.key; Key Svelte each to field.key so that the permutation preserves the control instance and line errors.

The names of FormItem and nested FormList are counted from the nearest list: name={[field.name, 'name']}. Model methods always receive the full path: ['users', field.name, 'name']. Nested Lists continue this rule for teams and participants. A separate nested Form starts a new paths context.

add(value, insertIndex?) without index appends to the end; remove(index) also accepts an array of indexes; move(from, to) carries the value along with the key. Drag and drop is not built in: the example uses the "Above" button.

An array of the initialValues form takes precedence, including the empty []. If there is no array, the list uses its initialValue. resetFields() returns the original data and recreates the row controls; The nested list example restores the initialValue list. Hiding a list preserves the values ​​but removes its local rules.

FormList rules only support custom validator(value, values). Pass meta.errors and meta.warnings to FormErrorList; example requires two participants and sets the message area to the alert or status role. FormList does not automatically add a DOM wrapper, signature, or error output. The rule with warningOnly: true creates an alert that does not block sending.

Check and send

Automatic validation runs on onChange by default. Set validateTrigger on Form for shared defaults or on Form.Item for one field. For example, onBlur validates when focus leaves the control. Use false to disable event-driven validation. Submission and validateFields() still validate fields.

Top level rules can be passed to createForm; they work without FormItem in the DOM. FormItem.rules sets local rules, including for a nested path, and takes precedence over model rules. Explicit rules={[]} disables the model rules for this field. When a FormItem is deleted, its local rules are removed and the value is retained.

required, min, max and pattern cover simple restrictions. Its validator(value, values) returns the error text or undefined; asynchronous verification returns a Promise of the same result. Asynchronous example shows wait and protection against stale response. Conditional check changes FormItem.rules, then explicitly runs validation through touchField.

Mandatory marker and verification are two different things. FormItem.required controls the signature and rule required checks the value. For mandatory consent, check true in your own validator: false by itself is not considered a null value.

Result Where to process
All rules are met onFinish(values)
Field validation error onFinishFailed(error)
Error inside onFinish onError(error)

To send, use Button with htmlType="submit". While the Promise from onFinish is not completed, the model retains isSubmitting; the form blocks resubmission and disables its controls. Submission example separates query errors and field errors by storing the entered data for retry.

validateFields() runs the check without sending and returns the checked values ​​or rejects the Promise with errors. In validateFields([['profile', 'name']]) you can select paths to check; a successful result still contains a snapshot of the entire model, whereas Ant Design returns the selected part. The method accepts options as the first argument or after the list of paths. The validateFields and submit methods can be learned in model example.

Rule types and formats

type checks the value without converting store. The line '12' does not pass number or integer; the conversion is done explicitly in the owner handler. float requires a fractional number and rejects an integer. boolean with required takes false. Value types allow you to compare a string and a number in a model.

Type What is being checked
string Line; length is calculated in Unicode code points
number / integer / float Number without NaN / integer / non-integer
boolean Boolean value
array / object Array / non-null object other than array; object doesn't mean just plain object
date Valid date; the matching string or timestamp is converted only for the duration of the check
regexp / method / any RegExp or valid input for its constructor/function/any type
email / url / hex / tel Format email, URL, HEX color or phone
enum Strict match with one of the values ​​enum
pattern Checking a string value using the pattern pattern

enum is only enabled together with type: 'enum'. pattern accepts a RegExp or expression string. Formats and enumerations shows these restrictions without querying the server: a successful email or URL check does not confirm the address's availability.

Numerical validation does not guarantee finiteness: use Number.isFinite in the validator if necessary. The date's min/max/len are compared with the timestamp. To limit the length, specify the appropriate type: not all types use min/max/pattern. When type is explicit, the own validator replaces the built-in constraints of this rule; For independent checks, set separate rules.

Factories and nested rules

FormRule - object ValidationRule or synchronous ValidationRuleFactory: (form) => ValidationRule. The factory gets the current FormInstance and can read other values ​​via getFieldValue. It is called when checking and determining if it is required, so it should be clean, without queries or side effects. Asynchronous factories are not supported; The factory exception remains a runtime error. Current rule reads the modifiable minimum from the model.

For type: 'object' and type: 'array', the fields property specifies the rules for child keys. defaultField checks the elements of the array, and the object has its own keys without an explicit fields rule. Nested rules accept objects, not factories. The optional absent parent is skipped. For an array, defaultField is launched after successful check of the parent and explicitly specified fields; sparse gaps are not checked.

This is checking the contents of a single binding: errors on child values ​​go to the parent FormItem and do not register their own NamePath. If you need separate labels, metadata and focus of child fields, use named FormItem and FormList. Nested rules compares object and array; FormList.rules still only accepts custom validator.

Messages and localization of check

FormItem.messageVariables substitutes strings into messages of the form ${label}: минимум ${min}. Path name, rule parameters and label are available. For a rich label, specify the string alias explicitly: without it, the field name is used. Message Variables change the signature in the error, preserving the value and constraint.

The substitution is performed once. The unknown variable becomes the string undefined; \${label} saves the literal text ${label} in the finished template. In a JavaScript string literal, the backslash must be escaped. Custom variables only change the display, even if they override the name min or label.

ValidateMessages specifies general built-in error texts. Priority: rule.message → Form.validateMessages → ConfigProvider.form.validateMessages → locale.Form.defaultValidateMessages → embedded Russian text. Message templates show the priority of local messages and the provider.

Groups types, string, number, array, date and pattern are partially specified. Provider combines groups with a locale, and a local Form replaces the entire nested group specified: string: { min: ... } does not preserve the provider's string.max. The missing template gets inline text.

ValidateMessage - string or function () => string. Strings support printf markers %s, %d, %j, %%, then variable substitutions. Changing settings is applied at the next check; errors already shown are not automatically translated. For each Form, use its own model: if several Forms share one model, the messages are set by the last registered form.

Order, delay and rule transformation

validateFirst belongs to FormItem. false runs the rules in parallel and collects all messages, true sequentially stops at the first error, parallel selects the first completed blocking error. The warning does not bypass pending blocking rules: this is a deliberate difference from the observed upstream race. Order of rules shows messages and number of calls.

validateDebounce delays automatic validation after blur and touched field changes. The new check replaces the pending one; reset and deleting the field cancel the wait. validateFields and submit are checked immediately. validateOnly does not change the already shown check and does not cancel its timer. Debounce shows the number of calls without spoofing a network request.

transform synchronously prepares the value only for its rule. It does not change the store, values ​​of the second validator argument, or the input of the next rule. An exception becomes an error of this rule. To change the input itself, use the owner handler and setFieldValue, as in the normalize example.

len has priority over min/max: for a number it checks the number itself, for a string it checks the number of Unicode code points, for an array it checks the number of elements. whitespace rejects a non-empty string of only spaces; an empty optional value remains valid. Exact restrictions retain the original string with spaces upon successful check after trim. List rules still only support custom validator.

Test and touched modes

FormValidateOptions contains three independent flags, the default is false. Example modes allows you to combine them when checking the ['profile'] path.

validateOnly executes the rules and returns the result without changing the errors, warnings, touched and validating shown. Validation may still reject the Promise. Already shown messages are saved; The silent check itself does not make the field dirty. It can be used to evaluate the readiness of a form without showing errors prematurely. Normal blur checking continues to work regardless of this flag.

recursive includes registered fields within the selected path. Without it, the choice ['profile'] does not check the rules of child name and email. Crossing paths do not retrigger the same field; the string and numeric segments remain distinct.

dirty selects changed, touched and already checked by normal validation fields. Specified initial values ​​are also involved, including the empty string, 0, false, and null; a missing value or undefined does not itself include the field. Therefore, in the example, the name with the initial '' is checked immediately, and the email is checked after changing, blur, or regular checking. reset clears the dirty history, but the specified defaults remain the basis for selecting the field.

isFieldTouched(path) takes into account the field itself and known descendant models. The empty path [] answers whether at least one field is affected. In the example, name blur changes the attributes of the name, profile and entire form; silent checking does not change them. Writing a value using a setter does not in itself mean touched.

Warnings are read through getFieldWarning(path) and getFieldsError(). FormItem shows them in an accessible description without aria-invalid; errors take precedence. In the example, the short name raises a non-blocking warning.

The new validation call makes the previous Promise obsolete even when validating different fields. In this case, the visible messages of each field can be completed and updated independently: outOfDate refers to the result of the call, and not to the prohibition of showing all its field errors. Please check FormValidationError.outOfDate before using the image; protect the application result from late response and from unmounting, as in asynchronous example.

States of several fields

isFieldsTouched() reports whether at least one field is affected. isFieldsTouched(true) requires all valid bindings; FormList roots do not interfere with this condition. initialValues ​​containers without binding and rules are not considered additional controls. Model rules and explicitly affected fields are taken into account without FormItem.

The choice of names defines groups by prefixes. isFieldsTouched([['profile']], true) will become true after blur one field inside profile. To require both fields, list both full paths: [['profile', 'name'], ['profile', 'email']]. Example of group states shows these queries side by side. The request itself does not change the metadata; writing a value does not replace blur.

isFieldsValidating() checks for the presence of the validating flag in the entire model. In isFieldsValidating(names) the names match exactly, without including children: the ['profile', 'name'] check does not include the flag for ['profile']. In the example, the name and email responses arrive via different local timers, so the flags are completed one at a time. validateOnly does not enable validating and does not interrupt the display of the status of normal validation already in progress. For fields without rules, this flag is not automatically checked; it is set manually via setFields.

Empty list of names [] returns false for isFieldsTouched and isFieldsValidating; isFieldsTouched([], true) returns true. touched's [[]] selection is one group of the entire model, so with allTouched=true it doesn't require all the individual fields. Prefer isFieldsTouched(true) for checking all bindings.

After reset, the states are cleared, and late responses from the old check do not return them. FormList controls re-register their rules: an invalid line after reset still blocks submit and receives focus. In the group states example, the metrics appear after the FormItem is registered in the browser; SSR preserves the original fields and shows “—” instead of not yet connected states.

Read values

getFieldsValue reads multiple fields without running a check or changing their state. Example of reading values compares the projection of the fields with the full store:

Challenge Result
getFieldsValue() Registered FormItem/FormList and fields with model rules
getFieldsValue(true) The entire store, including values ​​without UI
getFieldsValue([['profile']]) Known fields and children profile; if there are no bindings, the value of the path itself
getFieldsValue({ filter: meta => meta?.touched ?? false }) Fields that have passed the metadata filter and list roots

The name list contains full NamePath values from the model root. An empty [] returns {} without calling the filter. A string containing a dot is treated as a literal key.

Without a filter, getFieldsValue(true) returns the store itself and getFieldsValue([[]]) returns a copy. The result type is Values in both cases. Other calls return FormValueProjection<Values>, which can omit nested fields and array entries.

The filter can be passed via config or as the second argument after names/true. It receives a FormFieldMeta with name, touched, validating, errors, warnings and validated. For an explicitly requested path without binding, null is returned: check this before reading metadata. When set to true, the filter selects bindings rather than arbitrary store keys. The validated flag is set by regular checking or changing the value via setFieldsValue; validateOnly doesn't change it.

FormList projects the registered row fields, then adds the missing list root as an empty array. The root is not passed to the filter, so a filter that always returns false will still leave people: []. Complete rows with data without controls are available via true without a filter. This result of the current implementation differs from the simplified description of List in the Ant Design documentation.

FormItem is registered after mount. Therefore, during SSR and first reading, the projection is not yet required to contain UI fields; for the full initial state read true. The touched flag itself does not register a value for the projection. In the example, you can show and hide the note: store will save it, and the projection will reflect the presence of the control.

Field values and states

Pass fields to control fields externally. Form applies the values and metadata after mount. During editing and validation, onFieldsChange receives the changed fields and the full snapshot. Applying fields does not call the callback.

setFields(entries) applies the FormFieldData entries in order. One entry can specify value, errors, warnings, touched and validating. When updating metadata, missing properties are preserved: updating errors does not reset warnings or touched. An empty message array or explicit undefined clears errors/warnings; value with undefined writes an empty value, and the absence of value does not change it.

Batch update applies a locally prepared server response: changes the login, shows an error and warning, and notes touched. The validator counter remains the same - the method does not run the rules. Metadata is only valid for known bindings or fields with model rules. The value can be written without the UI; metadata of such a path is ignored and is not deferred to a future mount.

Normal field validation with rules can replace manually specified messages. For a field without rules, manual errors/warnings/validating are saved; by themselves they do not block validateFields or submit. For blocking validation, add a validator. Do not use manual validating as proof of a working Promise: it is set and removed by the application.

Explicit validating=false also sets calculated validated=true without running the rules. The validated input does not override this computed flag. undefined for touched/validating is normalized to false. Changing value cancels the previous validation of the affected fields and removes their validating unless a new explicit flag is set. The old validator does not rewrite messages for the fresh value; simply updating messages without changing value does not cancel the active check.

Initial field values

The form's initialValues ​​takes precedence over FormItem.initialValue, including null, false, 0, and the empty string. The initialValue of the field is filled with undefined before the control is rendered, without marking the touched field. Changing prop does not overwrite the current value, but is applied during the next reset. Example separates the current draft from the new default.

For one path, do not set competing initialValue ​​of several Items. When the last registration is deleted, reset is no longer required to restore the default of the disappeared field. Inside FormList, set defaults on the form, list, or via add(defaultValue), and not on individual Item lines.

Selective reset

resetFields(names?) restores values ​​taking into account the priorities of the form's initialValues ​​and registered initialValue fields. Without an argument, the entire model is reset; with a list - only selected paths. Selective reset example compares values, metadata and re-creation of controls.

Challenge Values ​​ Field status
resetFields() Whole model All model fields
resetFields([['profile', 'name']]) One nested name Only binding with this exact path
resetFields([['profile']]) profile object with children Only binding of the profile itself, if it exists
resetFields(['people']) List array The selected FormList recreates the rows
resetFields([]) No changes No changes
resetFields([[]]) Whole store Metadata of named fields is not selected

The selection of metadata is precise, without automatically including descendants. In the example, the profile itself does not have a FormItem, so resetting the object will update the visible value of the name, but will preserve its touched/errors. To clear the name state, pass the full path ['profile', 'name']. The line with the dot remains the literal key; the numeric and string segments are different. Repeating a path does not duplicate a reset, and an unknown path gets undefined without creating a binding.

The contents of the selected FormItem are recreated, including a local draft and cleanup of controls. Its entire snippet, including nested FormItems, goes through the usual unmount/mount. This applies to regular fields when completely reset, as well as rows of the selected FormList. State stored by the parent component outside of these blocks must be reset separately. Unselected adjacent fields retain their controls, drafts, and selection; changing the data structure can separately change the composition of rows through the normal lifecycle of the list.

The associated native control restores focus after re-creation if the owner remains on the page and the user does not change focus. This keeps the draft InputNumber running on a soft reset. Pressing a button that puts focus on it should not force it back into the field.

FormList initialValues ​​of forms take precedence over the current initialValue of the root list. If there is no form value, the default of the list is applied; if multiple lists set initialValue to the same path, reset does not select an arbitrary default. After re-creation, row rules and persistent list keys continue to work.

Reset protects against late validation: the former result does not return a reset field error. In the example, you can run a name check, reset the exact path, and wait for an outdated result message. An unselected check may also become outOfDate after changing the shared snapshot, so always check for this attribute.

Scrolling, ref and focus errors

getFieldInstance(name) returns the published ref of the mounted control; before mount and after removal - undefined. focusField delegates to focus ref, otherwise uses the associated native control. FormItem.controlRef allows you to explicitly pass a ref to your own composition and takes precedence over built-in registration.

scrollToField(name, options) scrolls to a ref or native id and respects CSS scroll-margin. The default if-needed behavior aligns to the nearest edge. Set focus: true to also call focusField. boundary limits which scroll containers are visited. behavior accepts a native behavior or a callback receiving the calculated actions. The returned Promise is not awaited.

Form.scrollToFirstError is executed after onFinishFailed only for the actual error. true scrolls without focus; the object supports focus, false disables the action. If the setting is missing for provider, the previous native autofocus of the first invalid control is retained. Scrolling shows local area and separate focus control.

Dependencies, Reset and Modal

Call Form.useWatch() during component initialization. Read the reactive value from markup or $derived. The hook accepts a field path or a selector. Set preserve: true to include unregistered fields. The watch example updates a greeting with the name, and the registration example shows dependent validation.

resetFields() returns initial values, clears metadata and recreates the contents of the registered FormItem and FormList. For the shape part use selective reset. For data loaded after the model was created, use setFieldsValue: changing the defaultValue of individual controls will not update the model. Reset the state of the parent component separately.

In example of a form in Modal, the application explicitly chooses when to reset and close the window. Hiding a window does not in itself mean clearing the values. A save error should leave an opportunity to correct the data or repeat the request.

Don't nest native HTML forms within each other. If an internal group needs a common Form context without additional DOM, use component={false}. This Form does not add its own submit/reset handlers; sending is owned by the external form. Context without wrapper shows the general model and a separate variant.

General settings and semantic design

Form.size and Form.disabled set defaults to child controls, including nested compositions. The local prop control and the closest ConfigProvider take precedence; isSubmitting additionally blocks repeated actions. Form.variant maintains the separate inheritance order shown in the context without a wrapper.

ConfigProvider.form sets colon, labelAlign, labelWrap, requiredMark, tooltip, scrollToFirstError and decoration. A nested record, including {}, replaces the entire parent record. Local props Form take precedence. size/disabled are not included in this record.

classNames/styles support root/label/content/help/helpItem/extra object or callback from resolved props. Classes are accumulated, CSS lines follow local styling priority; local style overrides styles.root. FormItem.rootClassName/style refers to the layout root. Semantic example combines defaults provider and callback Form without manually searching internal DOM nodes.

Examples

name@example.com
—

Regular shape

Required fields, labels, errors, focus and reset.

—

Model methods

Fill, validateFields, submit and restore initialValues.

Prepare errors, then compare the reset of the profile object and the exact name path. You can leave an incomplete numeric entry in the budget field. A full reset recreates all fields, a selective reset recreates the contents of the selected FormItem or rows of the selected FormList.

Name touched
no
Neighbor touched
no
Name validating
no
{ "profile": { "name": "Анна", "budget": 12 }, "note": "Соседнее поле", "people": [ { "name": "Борис" } ] } —

Selective field reset

Exact paths resetFields, parent and child metadata values, re-creation of InputNumber and FormList rows, late validation.

The projection includes only registered row fields. The full store also retains the role, internal and hidden note. Even if all fields are excluded, the root of the FormList remains an empty array.

Select reading method. —

Read field values

getFieldsValue: registered fields, full store, NamePath, nullable filter and FormList projection.

setFields does not run rules. Re-verification replaces login messages. For a field without rules, manual messages and validating are saved and do not themselves block sending.

Calls validator
0
Login touched
no
Yes validating
no
—

Batch update fields

setFields: values, errors/warnings, touched and manual validating without automatic checking.

—

Nested paths and field rules

NamePath, literal key with dot, local rules and partial object update.

The initial value is set.
Without initial value.
— Name: no Profile: no All form: no

Test modes

validateOnly, recursive and dirty for profile path. The name has an initial value, the email is missing; isFieldTouched takes children into account.

The admin name is taken.
The address taken@example.com is busy.

Touched

At least one field
—
All form fields
—
Group profile
—
Both profile fields
—

Validating

Any field is checked
—
Name is being checked
—
Email is being verified
—
The profile itself is checked
—
—

Multiple field states

isFieldsTouched: any field, all fields and groups. isFieldsValidating: precise paths, normal and silent validation. The responses are simulated by local timers.

Member 1
Member 2
—

Dynamic list

FormList: adding, inserting, deleting, moving, persistent keys and custom validation.

Team 1
—

Nested lists

Relative names of FormItem, full model paths, list initialValue and reset.

Field layout

vertical/horizontal/inline and local layout of a separate FormItem.

Trip, size and option

Form.disabled, Form.size and Form.variant; the general ConfigProvider remains fallback.

The form has not been submitted yet.

Context without wrapper

Form.component=false, the general model and a variant of the closest Form without a nested HTML form.

Введите имя.

Observation of values

Form.useForm() creates a typed model. Form.useWatch() updates the greeting when the name changes.

—

Registration and dependencies

Password, repeat and validator with current model values.

admin is busy; the check takes 300 ms.
—

Asynchronous check

Busy login, isFieldValidating and protection against outdated results.

—

Conditional check

FormItem.rules changes with the condition; touchField runs the test.

New project

—

Form in Modal

The external submit button is connected to the real form via form/id.

₽
Model: 1200

Own control

The wrapper around InputNumber preserves the FormItem context and the numeric value.

Spaces are removed and letters become capitalized.
Model: —

Input normalization

Owner removes spaces and changes case to setFieldValue.

—

Asynchronous sending

Resend blocking, pending and onFinish error.

—

Date in model

Dayjs is stored directly, without application ISO/UTC serialization.

Field checked

Explicit checked/onCheckedChange and validator for consent.

Description in slot help
Permanent explanation in slot extra

Semantic styles and ConfigProvider.form

Object defaults of the provider, callback styles of the form and priority of local design.

Form Component Theme

Reactively apply label and indentation tokens, save input and RTL.

Change captions or window width

Columns and transfer of labels

responsive labelCol/wrapperCol, labelAlign, labelWrap, colon and line alignment without label.

The name is shown in the list. Initial values
The profile can be changed later. This explanation is saved next to the error.

Captions, tooltip and explanations

Snippet labels and available names, general hint, rich help and permanent extra.

Mandatory marks

Asterisk, no mark, optional and your requiredMark snippet without changing the rules.

Hiding preserves the meaning and rules. Code: —

Hidden registered field

hidden saves control, value and validation; a hidden field can be checked and reset.

Composite field without wrappers

Nameless layout, two noStyle bindings, error collection and local disabled/size border.

without status no errors no warnings

Field status and useFormItemStatus

Visual validateStatus separate from errors/ARIA; reactive getter fields hook.

10

Input validation icons

hasFeedback in Input, InputPassword, InputSearch, TextArea and InputNumber. validateStatus only changes appearance.

Date and time icons

The default suffix shows the validation icon. A custom suffix replaces it; local suffixIcon=true overrides provider settings.

Custom validation icons

Form.feedbackIcons sets form icons. hasFeedback.icons replaces the field renderer; false hides an error icon while retaining its message.

Initial field values

Priority of initialValues, FormItem.initialValue and new default for next reset.

Trim applies only to the rule: spaces are kept in the model.
An empty optional value is acceptable.
" ABCD " Not shipped yet

transform, len and whitespace

Convert for rule only, string/array length and check for non-empty string of spaces.

First: 0; second: 0

Procedure for checking rules

All messages, sequential stop and first completed error; call counters.

After the first blur, change the name: automatic verification waits for a pause. Submit checks immediately.
0

Delayed field validation

validateDebounce delays automatic verification; submit checks immediately.

Not requested yet

Scrolling and ref fields

scrollToField, getFieldInstance, scrollToFirstError and separate focus inclusion.

Input writes a string. The conversion is performed by a separate button, not a rule.
Float rejects integers.
Required accepts false. A validator is required to agree to the terms.
amount: string Not verified yet

Rule value types

Explicit integer, float and boolean; the string does not automatically become a number.

Guest is in the list, but is prohibited by the enum rule.
Not verified yet

Formats, enum and pattern

Email, URL, HEX, phone, strict enumeration and string pattern.

Factory synchronous and clean: reads the model when checking and calculating the obligation.
Not verified yet

Rule factories

Synchronous rule from the current FormInstance, without side effects.

One binding profile; the name and age rules do not create separate fields.
DefaultField checks each element of the array.
Not verified yet

Nested object and array rules

fields and defaultField check the contents of the same parent binding.

Message variables

Substitution of label/min and own hint for rich label.

The local group string replaces the entire provider group. For max, inline text is included.

Message templates

Priority of rule, form, provider and locale; replacing a nested group of patterns.

—
General: suite; local: project-form

Form and FormItem choose prefixes independently. FormList.prefixCls refers to the ErrorList, not the adjacent fields. Adaptive captions respect the screen*Max tokens of their topic area; changing the prefix preserves the model and rules.

Form CSS prefixes

Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.

API

Themes are checked against the official Form Ant Design 6.7.0 page and public types @woodger/antd. React Form.Item and createForm have different contracts: Below is the actual available Svelte API.

Example themes
ThemeExample or limitation
Basic UsageLabels, rules, sending and reset.
Form methodsExplicit methods of the createForm model.
resetFieldsSelective and full reset, exact NamePath, re-creation of field and list contents.
GetFieldsValue / FilterFuncProjection bindings, entire store, path list, nullable metadata filter and FormList roots.
Set fields statusBatch values, errors/warnings, touched and manual validating without automatic validation.
Form Layoutvertical/horizontal/inline; default is vertical.
Form mix layoutFormItem.layout specifies the location of an individual field.
Form disabledContext for disabling @woodger/antd controls.
Form variantsGeneral variant of fields via Form.variant with local exceptions.
No DOM wrappercomponent=false passes the context without an embedded HTML form.
Required stylerequiredMark: true/false/optional and your own snippet; the rules remain independent.
Form sizeSize of controls via Form.size with local exceptions.
label can wrapresponsive labelCol/wrapperCol, labelAlign, labelWrap and label:null.
No block rulewarningOnly shows a warning about the short name and does not block validation or submission.
Watch HooksThe reactive value from Form.useWatch() is the value at a path or the result of a selector.
Validate TriggerForm.validateTrigger sets the default validation events. FormItem.validateTrigger configures them for an individual field.
Validate OnlySilent checking, recursive path selection and dirty filter taking into account initial values.
Path PrefixNamePath supported; automatic prefix is ​​given by FormList. There is no arbitrary HOC prefix.
Dynamic Form ItemFormList: add with insertIndex, remove, move, local rules and list errors.
Dynamic Form nest ItemsObject strings with the relative name FormItem and the full path of the model.
Drag sortingmove saves row key; example uses a button. Drag and drop is not built in.
Complex Dynamic Form ItemNested FormList, initialValue and reset of teams and participants.
NestA segment array accesses a nested object; the line with the dot remains one key.
complex form controlNameless layout and clean noStyle bindings with error collection.
Customized Form Controlsvalue/callback of the own component and FormItem context.
Store Form Data into Upper Componentfields supplies values and metadata from an external model. onFieldsChange reports control edits and validation changes.
Control between formsForm.Provider groups named forms and reports changes and submissions.
Inline Login Forminline mode and local axis of a separate field.
Login FormEmail/password fields and rules checking.
RegistrationPassword confirmation via validator(value, values).
Advanced searchCSS grid and conditional FormItem; hidden values ​​are preserved.
Form in Modal to CreateNative form/id and explicit reset on opening.
Time-related ControlsDayjs directly into the model.
Handle Form Data ManuallysetFieldValue/setFieldsValue without mutation values.
Customized Validationvalidator returns a message or Promise.
Dynamic RulesReactive FormItem.rules and explicit double-check via touchField.
Dependenciesdependencies sets the field paths whose control edits can trigger revalidation.
getValueProps + normalizeTransformation in the owner handler, without props of the same name.
Slide to error fieldgetFieldInstance/focusField/scrollToField and scrollToFirstError; focus is turned on separately.
Other Form Controlschecked for Switch and number for InputNumber.
HiddenHidden binding saves value and validation.
FeedbackIconsForm defaults, local snippets and hiding an individual icon.
Validation feedbackhasFeedback for input, selection and dates; visual status is separate from rules.
Form.Item.useStatususeFormItemStatus returns reactive readonly getter fields.
Initial valuesPriority of form and field defaults, reset with new initialValue.
Validation rulestransform, exact length len and whitespace.
Validate FirstAll rules, sequential stop and first completed error.
Validate DebounceAuto check delay without submit delay.
Rich labels and helpSnippet labels, tooltip, available names, help and extra.
Custom semantic dom stylingObject and functional slots, ConfigProvider.form, rootClassName/style.
Rule value typesExplicit integer, float and boolean; the string does not automatically become a number.
Formats, enum and patternEmail, URL, HEX, phone, strict enumeration and string pattern.
Rule factoriesSynchronous rule from the current FormInstance, without side effects.
Nested object and array rulesfields and defaultField check the contents of the same parent binding.
Message variablesSubstitution of label/min and own hint for rich label.
Message templatesPriority of rule, form, provider and locale; replacing a nested group of patterns.

Form

PropertyDescriptionTypeDefault
prefixClsFull native Form prefix. FormItem and FormList select prefixes separately; local Form.prefixCls does not rename them. The empty string/undefined inherit ConfigProvider.stringConfigProvider.prefixCls + "-form"
validateMessagesBuilt-in error templates. rule.message takes precedence; the nested Form group replaces the entire provider group.ValidateMessagesConfigProvider.form / locale.Form
formPass the model from Form.useForm() or createForm to access it externally.FormInstance<Values>internal model
fieldsExternal values and metadata are applied after mount without calling onFieldsChange.readonly FormFieldData[]—
onFieldsChangeReports field changes from control edits and validation.(changedFields, allFields) => void—
validateTriggerDefault events for automatic field validation. Accepts a string, an array, or false.FormValidateTriggeronChange
childrenForm fields and actions.Snippetis required
layoutGeneral location; FormItem.layout can clarify the field axis.vertical | horizontal | inlinevertical
disabledDefaults child controls; the closest provider and local disabled take precedence. Sending blocks repeated actions.booleanConfigProvider.componentDisabled
variantOption for the fields of the nearest Form. Takes precedence over component settings and the general ConfigProvider.variant, but is inferior to the local variant of the field. undefined does not inherit the variant of the outer Form.Variantundefined
componentfalse leaves the context without a DOM wrapper, submit/reset and DOM attributes.'form' | falseform
onFinishAfter successful verification. Promise holds isSubmitting.(values: Values) => void | Promise<void>—
onFinishFailedRule errors; outOfDate is a legacy check.(error: FormValidationError<Values>) => void—
onErrorError in onFinish execution, separate from validation.(error: unknown) => void—
classClass of present form; native id, style and aria attributes are also available.string—
sizeSize of child controls; local size and closest provider take precedence.ComponentSizeForm / ConfigProvider
colonColon horizontal label; local FormItem.colon takes precedence.booleanConfigProvider.form / true
labelAlignLabel alignment; FormItem can refine it.left | rightConfigProvider.form / right
labelWrapTransferring labels inside selected columns.booleanConfigProvider.form / false
labelColAdaptive label and control columns; a local Item object replaces the entire global one.ColProps—
requiredMarkVisual mark only. Snippet gets label and { required }; the rules don't change.boolean | 'optional' | FormRequiredMark rendererConfigProvider.form / true
feedbackIconsThe ({ status, errors, warnings }) renderer returns icons by status. FormItem.hasFeedback enables them; a local icons renderer takes priority.FormFeedbackIcons—
tooltipTooltips Defaults; The icon appears only when the tooltip field is specified.FormTooltipPropsConfigProvider.form.tooltip
scrollToFirstErrortrue scrolls without focus, false disables action; object supports focus. Fires after onFinishFailed.boolean | FormScrollOptionsConfigProvider.form / native autofocus
rootClassNameAdditional class native form; component=false does not create root.string—
classNamesObject or callback; root/label/content/help/helpItem/extra. styles - CSS strings.FormSemanticConfigProvider.form
wrapperColSpeakers control; Nested Items do not inherit from the outer Item.ColProps—
stylesCSS lines by slots; local style overrides semantic root.FormSemanticConfigProvider.form.styles

FormItem

PropertyDescriptionTypeDefault
prefixClsThe full base Form prefix of the field (the Item class adds -item). Resolved regardless of Form.prefixCls; empty string/undefined inherit ConfigProvider.stringConfigProvider.prefixCls + "-form"
messageVariablesSubstitutions in messages: label/name and rule parameters. Only the text is overridden, not the restrictions; for a rich label, set the string label explicitly.Readonly<Record<string, string>>{}
nameWithout name only layout: without model binding, rules and native name. In the list, the name is relative to the FormList.NamePath—
labelText, number, array or snippet. null stores the offset of the columns; false/undefined/empty string hide the label without this offset.RenderEmptyContent—
childrenControl; value/checked and callback are passed explicitly.Snippetis required
helpRich explanation instead of missing errors/warnings; reset recreates the content.RenderEmptyContent—
requiredMarker and sign of mandatory control; does not add a validation rule.booleanby rules.required
rulesValidationRule objects or pure synchronous factories (form) => ValidationRule; priority over createForm.rules. An empty array disables model rules; when unmount, local rules are removed, the value is saved.readonly FormRule[]model rules
htmlForExplicit control identifier for label.stringgenerated id
classFormItem external container class.string—
extraConstant rich explanation next to errors/warnings; is associated with control and is recreated when reset.RenderEmptyContent—
initialValueFills undefined before render. initialValues ​​of the form takes precedence; the prop change is used by the future reset.unknown—
hiddenHides the block, preserving the control, value and registration of the rules.booleanfalse
noStylePure binding without layout; errors are collected by the nearest styled Item. help=false disables message transmission.booleanfalse
layoutLocal field location. Standalone Item defaults to vertical.horizontal | verticalForm.layout
labelAlignLocal label alignment.left | rightForm.labelAlign
labelColReplaces the generic object including {}.ColPropsForm.labelCol
wrapperColReplaces a generic object; does not inherit from the outer FormItem.ColPropsForm.wrapperCol
colonExplicit true includes the colon even when Form.colon=false.booleanForm.colon
tooltipContent or Tooltip object with icon-snippet; general defaults is set by Form.tooltip.FormItemTooltip—
validateFirstfalse collects all messages, true stops the rules in order, parallel selects the first error that completed.boolean | 'parallel'false
validateTriggerEvents that validate the field automatically. With false or an empty array, validation still runs on submit and explicit calls.FormValidateTriggerForm.validateTrigger
validateDebounceAutomatic validation delay in ms. validateFields and submit are fired immediately.number—
hasFeedbackIcon for the current status. false from the renderer hides it; null/undefined/an empty string/0 use the default. noStyle inherits the icon unless hasFeedback is explicitly set.boolean | { icons?: FormFeedbackIcons }false
validateStatusVisual status; an empty line disables automatic. Errors and aria-invalid are not cleared.FormValidateStatusby metadata
controlRefAn explicit DOM/ref with focus/nativeElement takes precedence and is returned by getFieldInstance without a wrapper.unknownregistration control
rootClassNameAdditional layout-root class.string—
styleroot CSS after component tokens; noStyle without hidden does not create a layout.string—

createForm

PropertyDescriptionTypeDefault
initialValuesInitial values, including nested objects and arrays. Optional fields may be missing; the model type is specified by createForm<values>.Valuesis required
rulesTop level rules; work without FormItem in the DOM. For nested fields, use FormItem.rules.FormRules<Values>{}

FormInstance

PropertyDescriptionTypeDefault
valuesReactive values; change via setters, do not bind:value to values.Readonly<Values>copy of initialValues
errorsTop level errors; nested errors are read via getFieldError/getFieldsError.Readonly<FieldErrors<Values>>{}
isSubmittingCheck/submit; resubmit returns busy.booleanfalse
submissionErrorLast callback sending error.unknownundefined
getFieldValueFull path value from root Form; the type of the known path is displayed, the type of the dynamic path is unknown.(name: NamePath) => NamePathValue<Values, Path>—
getFieldsValuePassing true or [[]] without a filter returns Values. Other calls return a projection that can omit nested fields and array entries. The FormGetFieldsValueConfig.filter callback receives FormFieldMeta | null.FormInstance<Values>["getFieldsValue"]bindings
getFieldsErrorPaths, errors and non-blocking warnings.(names?: readonly NamePath[]) => FieldError[]all fields
getFieldErrorMessages of one nested or root field.(name: NamePath) => readonly string[]—
getFieldWarningMessages warningOnly one field; are not included in errors.(name: NamePath) => readonly string[]—
isFieldTouchedConsiders the field itself and the path's known descendants; [] checks the entire model. The request does not change the metadata.(name: NamePath) => boolean—
isFieldsTouchedAlso accepts allTouched as a single argument. Without names, true requires all bindings except FormList roots. With names, true requires at least one touched field in each prefix group.(names?: readonly NamePath[], allTouched?: boolean) => booleanany field
isFieldValidatingFlag of any binding with an exact name: regular validation or manual setFields.validating. The validateOnly flag is not included.(name: NamePath) => boolean—
isFieldsValidatingDoes the selected fields have validating, including the one specified via setFields. Names are exact, without descendants; [] does not select fields. The request does not change the metadata.(names?: readonly NamePath[]) => booleanall fields
isFieldRequiredAvailability of required in current local or model rules.(name: NamePath) => boolean—
setFieldValueReplace the full path value, including the entire object or array.(name: NamePath, value) => void—
setFieldsValueRecursively combine ordinary objects; Replace arrays and class instances entirely.(next: PartialFormValues<Values>) => void—
setFieldsApply records in order without validation. value works without UI, metadata only for bindings. Changing value cancels the previous check. Manual field messages without rules do not by themselves block submit.(fields: readonly FormFieldData[]) => void—
touchFieldCheck the box and run the test.(name) => void—
resetFieldsRestore the values of the selected paths; metadata is selected by its exact name. The contents of the selected FormItem and FormList rows are recreated. [] doesn't change anything; [[]] resets store without selecting metadata named fields.(names?: readonly NamePath[]) => voidwhole model
validateFieldsAlso takes options as the first argument. The result contains the entire model; errors reject Promise. validateOnly does not change the messages; recursive and dirty filter fields.(names?: readonly NamePath[], options?: FormValidateOptions) => Promise<Values>all fields, flags false
submitsuccess/invalid/failed/busy; native Form calls this method on submit.(onFinish) => Promise<SubmissionResult<Values>>—
getFieldInstanceRef mounted control; before mount and after removing undefined. The Instance type specifies the calling code.<Instance = unknown>(name: NamePath) => Instance | undefined—
focusFieldDelegates focus ref or associated native control.(name: NamePath) => void—
scrollToFieldScroll to ref/native id; focus is turned on separately, the unknown field does nothing.(name: NamePath, options?: FormScrollOptions) => void—

FormValidateOptions

PropertyDescriptionTypeDefault
validateOnlyNo changes errors, warnings, touched and validating; saves messages already shown. Doesn't make the field dirty.booleanfalse
recursiveIncludes registered descendants of selected paths without re-checking for overlapping names.booleanfalse
dirtyChanged, touched, previously checked fields and specified defaults, except undefined. reset clears history, but does not exclude defaults.booleanfalse

FormFieldData

PropertyDescriptionTypeDefault
nameFull path from the model root; entries are applied in order.NamePathis required
valueReplace value, including explicit undefined; works without binding.unknownsave
errorsError messages. [] or undefined clears them; rules are not launched.readonly string[]save
warningsWarnings. [] or undefined clears them regardless of errors.readonly string[]save
touchedManual field marking; undefined is normalized to false.booleansave
validatingManual flag, including fields without rules. false also sets validated=true.booleansave; when changing value - false
validatedAccepted, but does not replace the calculated flag; do not use to control validation.booleanis calculated

FormFieldMeta

PropertyDescriptionTypeDefault
nameSegments of the selected registered field.readonly (string | number)[]way binding
touchedMarked by blur, touchField, submit, or setFields.booleanfalse
validatingNormal check or manual flag setFields; validateOnly doesn't change it.booleanfalse
errorsCurrent messages, including manual ones.readonly string[][]
warningsCurrent non-blocking warnings.readonly string[][]
validatedCompleted normal validation, changed via setFieldsValue or explicit validating=false. validateOnly does not change the flag.booleanfalse

FormList

PropertyDescriptionTypeDefault
prefixClsPrefix of nested FormErrorList; empty string/undefined inherit ConfigProvider, adjacent FormItems are independent.stringConfigProvider.prefixCls + -form
namePath to array; in a nested list relative to the parent FormList.NamePathis required
initialValueFills the missing array and participates in reset. The form's initialValues ​​takes precedence, including [].readonly unknown[]—
rulesOnly custom validators with Svelte signature (value, values). Errors are output from meta.errors.readonly FormListRule[]—
childrenList markup without additional DOM wrapper. The key of each block each is field.key; Model bindings use the full path.Snippet<[FormListFieldData[], FormListOperation, FormListMeta]>is required

FormListOperation

PropertyDescriptionTypeDefault
addAdd value and new key. An incorrect insertion index is also appended to the end.(defaultValue?: unknown, insertIndex?: number) => voidto the end
removeDelete rows; duplicates and missing indexes do not remove neighbors.(index: number | readonly number[]) => void—
moveTransfer value and key. Invalid and fractional indexes are ignored.(from: number, to: number) => void—

FormListFieldData

PropertyDescriptionTypeDefault
nameCurrent row position for relative FormItem.name.numberindex
keyString identity for keyed each; persists when move and neighbors are removed.numberstable key

FormListMeta

PropertyDescriptionTypeDefault
errorsList check messages; display them yourself next to the actions.readonly string[][]
warningsMessages warningOnly list rules; do not block submit.readonly string[][]

FormListRule

PropertyDescriptionTypeDefault
validatorArray check; message on error, void on success.(value, values) => string | void | Promise<string | void>is required
messagePublic field of the rule. Custom validator returns its own message.string—
warningOnlyPlace the custom validator result in meta.warnings without blocking submission.booleanfalse

FieldError

PropertyDescriptionTypeDefault
nameSource path segments; numeric and string indexes are different.(string | number)[]way
errorsField rules messages.string[][]
warningsMessages warningOnly; in errorFields are transmitted along with errors for this field.string[][]

FormValidationError

PropertyDescriptionTypeDefault
valuesValues at the start of the test.Readonly<Values>photo
errorFieldsErrors with full nested paths.readonly FieldError[][]
errorsProjection of top-level errors.FieldErrors<Values>{}
outOfDateValidation has become obsolete after changing, reset, deleting a field, or making a new call to validation, even a different field. Visible messages of individual fields are completed independently.booleanfalse

ValidationRule

PropertyDescriptionTypeDefault
typestring, number, integer, float, boolean, array, object, date, regexp, method, any, enum, email, url, hex, tel or pattern. Store is not converted. Float rejects integers.ValidationRuleTypeimplicit check
enumAllowed values ​​for type:enum; strict comparison without type conversion.readonly unknown[]—
fieldsChild rules for type:object/array. Messages remain with the parent binding; individual fields are not registered.Readonly<Record<string, ValidationRule | readonly ValidationRule[]>>—
defaultFieldRule for elements of array or other own keys of object. Nested factories are not supported.ValidationRule—
requiredChecks for an empty value. false and 0 are considered values.booleanfalse
minMinimum number or string/array length.number—
maxMaximum number or length of string/array.number—
patternString value pattern.RegExp | string—
messageOwn error text with substitutions ${variables}; priority over validateMessages.stringmessage rules
validatorError message; void on success. With an explicit type, the custom validator replaces the built-in constraints. For consent, check true explicitly.(value, values) => string | void | Promise<string | void>—
warningOnlyThe message becomes a warning and does not block validateFields/submit or make the field required.booleanfalse
lenThe exact number, the number of Unicode code points of a string, or the length of an array. Takes precedence over min/max.number—
whitespaceRejects a non-empty string of all spaces; an empty optional value is acceptable.booleanfalse
transformSynchronous conversion for this rule only; is not written to store and is not passed on to the next rule. The exception becomes an error.(value: FormValue) => FormValue—

ValidateMessages

PropertyDescriptionTypeDefault
defaultGeneral pattern of unknown restriction. ValidateMessage - string or () => string.ValidateMessageembedded text
requiredRequired value; ${label} and ${name} are available.ValidateMessageembedded text
enumThe value is outside the enumeration.ValidateMessageembedded text
whitespaceA string of spaces.ValidateMessageembedded text
typesType and format errors: string, number, integer, float, boolean, array, object, method, regexp, date, email, tel, url, hex.Partial<Record<type, ValidateMessage>>{}
stringString length patterns; the values ​​are of type ValidateMessage.{ len?, min?, max?, range? }{}
numberNumerical restrictions.{ len?, min?, max?, range? }{}
arrayNumber of array elements.{ len?, min?, max?, range? }{}
dateDate errors.{ format?, parse?, invalid? }{}
patternPattern mismatch.{ mismatch?: ValidateMessage }{}

FormErrorList

PropertyDescriptionTypeDefault
errorsError messages, including strings, numbers and Svelte snippets.readonly RenderEmptyContent[][]
warningsWarnings shown after errors.readonly RenderEmptyContent[][]
helpReplaces errors/warnings for any value other than null/undefined, including false, 0, and the empty string.RenderEmptyContentundefined
helpStatusstatus class for help: success, warning, error, validating or empty string.FormValidateStatusundefined
fieldIdSets the container id <fieldId>_help for explicit association with the field.string—
classMessage container class; in the list its prefixCls is inherited.string—
onVisibleChangedAfter appearing or hiding. Not called for an initial empty list and after unmount.(visible: boolean) => void—

useFormItemStatus()

PropertyDescriptionTypeDefault
statusreadonly getter; empty string for pristine Item. Read through the object, destructuring creates a snapshot.FormValidateStatus | undefinedundefined outside Item
errorsReactive messages of the nearest FormItem.readonly string[][]
warningsNon-blocking warnings of the nearest FormItem.readonly string[][]

FormScrollOptions

PropertyDescriptionTypeDefault
blockVertical alignment.ScrollLogicalPositionnearest
inlineHorizontal alignment.ScrollLogicalPositionnearest
scrollModeScroll only when necessary or always.'if-needed' | 'always'if-needed
boundaryBoundary for traversing scroll containers.Element | ((parent: Element) => boolean)—
behaviorNative behavior or callback of calculated actions; Promise callback is not expected.ScrollBehavior | ((actions) => unknown)auto
focusCall focusField after scrolling. The scroll calculation includes CSS scroll-margin.booleanfalse

ConfigProvider.form

PropertyDescriptionTypeDefault
validateMessagesGeneral form templates, on top of the locale with nested groups combined; local Form.validateMessages takes precedence.ValidateMessageslocale.Form.defaultValidateMessages
colonGeneral horizontal label colon.booleantrue
labelAlignAlignment of labels.left | rightright
labelWrapTransfer of labels.booleanfalse
requiredMarkVisual mandatory mark.FormRequiredMarktrue
classNative form class.string—
styleCSS native form.string—
classNamesSemantic slots classes.FormSemantic—
stylesCSS lines semantic slots.FormSemantic—
tooltipDefaults prompt fields.FormTooltipProps—
scrollToFirstErrorGeneral behavior after an unsuccessful submit.boolean | FormScrollOptions—

Form supports nested NamePath, lists, metadata, selective reset, field defaults, and scrolling to errors. Connect the value with a control snippet or pass the value and change handler explicitly. Set validation dependencies with dependencies and choose the events with validateTrigger. Set the size with Form.size and the field variant with Form.variant. Use Form.Provider to coordinate forms.

Form.component=false provides context without a native form element. ref.submit() submits the mounted form programmatically. The example shares the outer form model, so its native actions cover both fields. The nearest Form without a variant clears the outer form variant. The component setting or ConfigProvider.variant then applies.

Semantic DOM

Form and ConfigProvider.form support object and functional classNames/styles. styles values ​​are CSS strings; local style overrides semantic root. FormItem accepts class/rootClassName/style. Captions, tooltip, help and extra are isolated from field binding; The complex label is associated with the control via aria-labelledby.

Semantic slots Form
ElementPurpose
rootNative form; missing when component=false.
labelField label, including requiredMark and tooltip.
contentchildren area inside control.
helpBlock errors/warnings or help.
helpItemSeparate message or rich help wrapper.
extraPermanent explanation next to messages.
Actual markings
ElementPurpose
form.ant-formBy default, a real form with native submit/reset. component=false passes only the context, without the DOM and handlers.
.ant-form-itemField container, verification statuses and class.
.ant-form-item-labelLabel label, htmlFor and mandatory marker.
.ant-form-item-controlControl and accessible description.
.ant-form-item-explainField errors and warnings; FormItem links them via aria-describedby. The warning does not set aria-invalid.
.ant-form-item-extrahelp without errors/warnings and a separate permanent extra.
[aria-invalid]Invalid control. Scrolling and focus after a failed send is controlled by scrollToFirstError.
FormList (no DOM)The list itself does not create a wrapper. Fieldset, legend, row actions and message roles belong to the example.
FormErrorListContainer ant-form-item-explain and separate error/warning messages. The ant-form-item class and the alert/status role are specified by the example wrapper.

Registration tokens

Form tokens apply to captions and indentation, including inline layout. The example switches them without resetting the form model; the RTL direction is maintained. The current values ​​of the common tokens are shown below.

TokenPurpose
labelRequiredMarkColorMandatory marker color.
labelColorLabel color.
labelFontSizeLabel font size.
labelHeightLabel height.
verticalLabelHeightVertical label height.
labelColonMarginInlineStartIndent to colon.
labelColonMarginInlineEndIndentation after colon.
itemMarginBottomBottom padding of FormItem.
inlineItemMarginBottomBottom margin of the field in inline layout.
verticalLabelPaddingPadding vertical label.
verticalLabelMarginMargin of vertical label.
Common tokens of the current topic
TokenMeaning
colorTextrgba(0,0,0,0.88)
colorError#ff4d4f
colorTextSecondaryrgba(0,0,0,0.65)
fontSize14
lineHeight1.5714285714285714
marginLG24
paddingXS8

FAQ

Why doesn't FormItem pass value to the child control?

Use the control snippet on Form.Item to access the mapped field props. You can also pass value or checked and a change handler explicitly. The basic form shows the explicit connection.

Why doesn't defaultValue populate the model?

The model is created from initialValues. When a control receives an explicit value from the model, it determines the value shown. For initial data, use initialValues or default of a separate FormItem, for the server response after loading - setFieldsValue.

How to check password confirmation and other dependencies?

Compare values in validator(value, values). Set dependencies to the full paths the field depends on. Editing one of those controls can trigger validation again. Use $derived for computed text. The registration example shows revalidation of a related field.

Why doesn't the line with a dot access the nested field?

The string remains the literal key. Pass ['profile', 'name'] for the nested value rather than 'profile.name'. Inside the FormList, the FormItem is given a relative name; reading and writing through model methods requires the full path from the root of the form. Example paths shows this difference.

Why should line errors move with it?

Key each by field.key, not by index. The current field.name changes when move or the adjacent row is deleted, but the key and control instance are preserved. Dynamic list uses this rule for values ​​and local errors.

What is more important: the initialValues of the form or the initialValue of the list?

The form value takes precedence even if it is an empty array. FormList.initialValue only fills the missing array. The initial values ​​of the individual FormItems in the list are not set; use form, list or add(defaultValue).

Where to display FormList errors?

Snippet receives meta.errors and meta.warnings. Pass them to FormErrorList, as in example: the wrapper class ant-form-item preserves the styling, and role="alert" for errors and role="status" for warnings declare the messages. FormErrorList also accepts help, which replaces lists of messages. Nested field errors are read through getFieldError and getFieldsError; form.errors contains only the top level.

Why does required not require you to enable Checkbox?

The value false is valid for a boolean field and is not empty. For consent, add a validator that only accepts true. The visual mandatory marker does not perform the check itself.

How to check fields without sending data?

Call validateFields() and process the rejected Promise. By default the method shows errors. validateFields({ validateOnly: true }) checks without changing messages; the choice of paths and options can be combined. Test modes show the differences between validateOnly, recursive and dirty.

Why is dirty checking a field that I haven't edited yet?

An initial value other than undefined already includes the field in the dirty filter. Even an empty string is considered a given default. After reset, such fields continue to participate; The history of changes and routine checks is reset. This is separate from touched, which is counted through blur, touchField and submit.

Why does checking another field make the same outOfDate result?

The freshness of the Promise applies to the entire model, so a newer call to validation makes the previous result obsolete. Messages from different fields can be displayed independently. Do not use an outdated snapshot for submission or application result; this rule also applies to validateOnly.

Why did allTouched for the profile group become true after one field?

In isFieldsTouched(names, true), each names element defines a group. One touched child in each group is enough. For all individual fields, list their leaf paths, or call isFieldsTouched(true) without a list of names. Example states shows the difference.

Why is the parent path's validating false when its field is validated?

isFieldsValidating matches exact names. Pass the full path of the field or call the method without names for the entire model. This is different from prefix selection in touched queries. Silent checking does not include validating.

Where to show the server error?

For a specific field error, use setFields with full name and errors, as in batch update. For a field without rules, a manual error does not itself block submit; For repeated blocking check, a validator is needed. For onFinish execution error, use onError and application state. onFinishFailed is for rule errors. Asynchronous example saves the entered values ​​for resending.

Why doesn't getFieldsValue return all initialValues?

Without arguments, the method reads the bindings, not all the store keys. UI fields are registered after mount; fields with model rules are available without UI. The entire store, including hidden values, returns getFieldsValue(true) without a filter. Reading example shows the difference and null for the metadata of an explicitly selected unregistered path.

Why does a filter that excludes all fields leave people: []?

The root of the FormList is filled separately from the filter. After excluding the string fields, an empty list array is left. Read the full row values, including data without controls, via getFieldsValue(true).

Does resetFields recreate all controls?

Without an argument, the contents of all registered FormItems and FormList strings are recreated. When selecting names, only the corresponding bindings are recreated. Adjacent fields are preserved and the state of the form's parent is reset separately. Selective example shows InputNumber and list; nested lists — restoration of initialValue.

Why did the profile reset keep the nested name error?

The parent's values ​​are restored along with the children, but the metadata is retrieved from the exact path. To clear the error and touched name, call resetFields([['profile', 'name']]). In example you can compare both actions.

How to store date and convert input?

Dayjs is stored directly in the model. The format for the server API, UTC or ISO, is chosen by the application when submitting. Date in model saves the original object. Input normalization converts the value in the handler before setFieldValue; FormItem does not have the normalize property of the same name.

Is it possible to use a custom Svelte field component?

Yes, if it accepts a value and reports a change. Link it to the model explicitly, save the label, an accessible name, and the ability to focus an invalid control. Own control wraps InputNumber and uses the same update contract.

How to adjust the indentation and design of the form?

Use vertical/horizontal/inline, labelCol/wrapperCol and local layout Item. Form and ConfigProvider.form support semantic classNames/styles; FormItem - class/rootClassName/style. See semantic example and speakers.

How is hidden different from removing a field?

hidden preserves DOM, meaning and rules. With unmount, local rules are removed. noStyle manages the layout separately, preserving the binding.

Why didn't transform remove spaces from Input?

transform prepares a value only for its rule. To change the store, use setFieldValue in the input handler.

Why didn't explicit success remove aria-invalid?

validateStatus changes the visual status. This error needs to be fixed or the metadata of the model needs to be changed.

Why was hook status not updated after destructuring?

useFormItemStatus returns a getter object. Read its fields in markup or $derived rather than storing separate initial values.