You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a value or validation result changes, `notify(name)` fires and every subscribed `FormItem` checks if the notification is relevant to it.
26
+
27
+
### Form — The Wrapper
28
+
29
+
- Creates (or accepts via `form` prop) a `FormInstance`, stored in a `useRef`
30
+
- Provides it to children via `FormInstanceContext`
31
+
- Provides layout options (`labelCol`, `wrapperCol`, `validateTrigger`, `layout`) via `FormOptionsContext`
32
+
- Handles **submit**: calls `validateFields()` on all fields, then routes to `onFinish` or `onFinishFailed`
33
+
- Handles **reset**: calls `resetFields()` which resets values to `initialValues` and notifies all fields with `'*'`
34
+
35
+
### Form.Item — The Field Connector
36
+
37
+
Each `Form.Item` with a `name` prop:
38
+
39
+
1.**Registers rules** — On mount, calls `form.setFieldRules(name, rules)`
40
+
2.**Subscribes** — Calls `form.subscribe(callback)` in a `useEffect`. Updates local `value`/`error` state only if the notification matches its own `name` (or either side uses `'*'`)
41
+
3.**Injects props via `cloneElement`** — The child component gets:
42
+
-`value` (or the prop name from `valuePropName`) — bound to `form.getFieldValue(name)`
// Pass to <Form form={form}> to control the form programmatically
55
+
```
56
+
57
+
If no `form` prop is provided, `Form` creates one internally.
58
+
59
+
### Validation (form-helper.ts)
60
+
61
+
The `validate` function checks a value against a `Rule` supporting: `required`, `type`, `max`, `min`, `len`, `enum`, `pattern`, `whitespace`, `transform`, and custom `validator` functions.
0 commit comments