mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
feat: Form support validateTrigger (#23972)
This commit is contained in:
parent
116af77548
commit
fafa3b7e51
@ -16,26 +16,27 @@ High performance Form component with data scope management. Including data colle
|
||||
|
||||
### Form
|
||||
|
||||
| Property | Description | Type | Default |
|
||||
| --- | --- | --- | --- |
|
||||
| component | Set the Form rendering element. Do not create a DOM node for `false` | ComponentType \| false | form |
|
||||
| colon | Configure the default value of `colon` for Form.Item. Indicates whether the colon after the label is displayed (only effective when prop layout is horizontal) | boolean | true |
|
||||
| fields | Control of form fields through state management (such as redux). Not recommended for non-strong demand. View [example](#components-form-demo-global-state) | [FieldData](#FieldData)\[] | - |
|
||||
| form | Form control instance created by `Form.useForm()`. Automatically created when not provided | [FormInstance](#FormInstance) | - |
|
||||
| hideRequiredMark | Hide required mark for all form items | boolean | false |
|
||||
| initialValues | Set value by Form initialization or reset | object | - |
|
||||
| labelAlign | text align of label of all items | `left` \| `right` | `right` |
|
||||
| labelCol | label layout, like `<Col>` component. Set `span` `offset` value like `{span: 3, offset: 12}` or `sm: {span: 3, offset: 12}` | [object](/components/grid/#Col) | - |
|
||||
| layout | Form layout | `horizontal` \| `vertical` \| `inline` | `horizontal` |
|
||||
| name | Form name. Will be the prefix of Field `id` | string | - |
|
||||
| scrollToFirstError | Auto scroll to first failed field when submit | false | - |
|
||||
| size | Set field component size (antd components only) | `small` \| `middle` \| `large` | - |
|
||||
| validateMessages | Validation prompt template, description [see below](#validateMessages) | [ValidateMessages](https://github.com/react-component/field-form/blob/master/src/utils/messages.ts) | - |
|
||||
| wrapperCol | The layout for input controls, same as `labelCol` | [object](/components/grid/#Col) | - |
|
||||
| onFinish | Trigger after submitting the form and verifying data successfully | Function(values) | - |
|
||||
| onFinishFailed | Trigger after submitting the form and verifying data failed | Function({ values, errorFields, outOfDate }) | - |
|
||||
| onFieldsChange | Trigger when field updated | Function(changedFields, allFields) | - |
|
||||
| onValuesChange | Trigger when value updated | Function(changedValues, allValues) | - |
|
||||
| Property | Description | Type | Default | Version |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| component | Set the Form rendering element. Do not create a DOM node for `false` | ComponentType \| false | form | |
|
||||
| colon | Configure the default value of `colon` for Form.Item. Indicates whether the colon after the label is displayed (only effective when prop layout is horizontal) | boolean | true | |
|
||||
| fields | Control of form fields through state management (such as redux). Not recommended for non-strong demand. View [example](#components-form-demo-global-state) | [FieldData](#FieldData)\[] | - | |
|
||||
| form | Form control instance created by `Form.useForm()`. Automatically created when not provided | [FormInstance](#FormInstance) | - | |
|
||||
| hideRequiredMark | Hide required mark for all form items | boolean | false | |
|
||||
| initialValues | Set value by Form initialization or reset | object | - | |
|
||||
| labelAlign | text align of label of all items | `left` \| `right` | `right` | |
|
||||
| labelCol | label layout, like `<Col>` component. Set `span` `offset` value like `{span: 3, offset: 12}` or `sm: {span: 3, offset: 12}` | [object](/components/grid/#Col) | - | |
|
||||
| layout | Form layout | `horizontal` \| `vertical` \| `inline` | `horizontal` | |
|
||||
| name | Form name. Will be the prefix of Field `id` | string | - | |
|
||||
| scrollToFirstError | Auto scroll to first failed field when submit | false | - | |
|
||||
| size | Set field component size (antd components only) | `small` \| `middle` \| `large` | - | |
|
||||
| validateMessages | Validation prompt template, description [see below](#validateMessages) | [ValidateMessages](https://github.com/react-component/field-form/blob/master/src/utils/messages.ts) | - | |
|
||||
| validateTrigger | Config field validate trigger | string \| string[] | 'onChange' | 4.3.0 |
|
||||
| wrapperCol | The layout for input controls, same as `labelCol` | [object](/components/grid/#Col) | - | |
|
||||
| onFinish | Trigger after submitting the form and verifying data successfully | Function(values) | - | |
|
||||
| onFinishFailed | Trigger after submitting the form and verifying data failed | Function({ values, errorFields, outOfDate }) | - | |
|
||||
| onFieldsChange | Trigger when field updated | Function(changedFields, allFields) | - | |
|
||||
| onValuesChange | Trigger when value updated | Function(changedValues, allValues) | - | |
|
||||
|
||||
### validateMessages
|
||||
|
||||
|
@ -17,26 +17,27 @@ title: Form
|
||||
|
||||
### Form
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| component | 设置 Form 渲染元素,为 `false` 则不创建 DOM 节点 | ComponentType \| false | form |
|
||||
| colon | 配置 Form.Item 的 `colon` 的默认值。表示是否显示 label 后面的冒号 (只有在属性 layout 为 horizontal 时有效) | boolean | true |
|
||||
| fields | 通过状态管理(如 redux)控制表单字段,如非强需求不推荐使用。查看[示例](#components-form-demo-global-state) | [FieldData](#FieldData)\[] | - |
|
||||
| form | 经 `Form.useForm()` 创建的 form 控制实例,不提供时会自动创建 | [FormInstance](#FormInstance) | - |
|
||||
| hideRequiredMark | 隐藏所有表单项的必选标记 | boolean | false |
|
||||
| initialValues | 表单默认值,只有初始化以及重置时生效 | object | - |
|
||||
| labelAlign | label 标签的文本对齐方式 | `left` \| `right` | `right` |
|
||||
| labelCol | label 标签布局,同 `<Col>` 组件,设置 `span` `offset` 值,如 `{span: 3, offset: 12}` 或 `sm: {span: 3, offset: 12}` | [object](/components/grid/#Col) | - |
|
||||
| layout | 表单布局 | `horizontal` \| `vertical` \| `inline` | `horizontal` |
|
||||
| name | 表单名称,会作为表单字段 `id` 前缀使用 | string | - |
|
||||
| scrollToFirstError | 提交失败自动滚动到第一个错误字段 | false | - |
|
||||
| size | 设置字段组件的尺寸(仅限 antd 组件) | `small` \| `middle` \| `large` | - |
|
||||
| validateMessages | 验证提示模板,说明[见下](#validateMessages) | [ValidateMessages](https://github.com/react-component/field-form/blob/master/src/utils/messages.ts) | - |
|
||||
| wrapperCol | 需要为输入控件设置布局样式时,使用该属性,用法同 labelCol | [object](/components/grid/#Col) | - |
|
||||
| onFinish | 提交表单且数据验证成功后回调事件 | Function(values) | - |
|
||||
| onFinishFailed | 提交表单且数据验证失败后回调事件 | Function({ values, errorFields, outOfDate }) | - |
|
||||
| onFieldsChange | 字段更新时触发回调事件 | Function(changedFields, allFields) | - |
|
||||
| onValuesChange | 字段值更新时触发回调事件 | Function(changedValues, allValues) | - |
|
||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| component | 设置 Form 渲染元素,为 `false` 则不创建 DOM 节点 | ComponentType \| false | form | |
|
||||
| colon | 配置 Form.Item 的 `colon` 的默认值。表示是否显示 label 后面的冒号 (只有在属性 layout 为 horizontal 时有效) | boolean | true | |
|
||||
| fields | 通过状态管理(如 redux)控制表单字段,如非强需求不推荐使用。查看[示例](#components-form-demo-global-state) | [FieldData](#FieldData)\[] | - | |
|
||||
| form | 经 `Form.useForm()` 创建的 form 控制实例,不提供时会自动创建 | [FormInstance](#FormInstance) | - | |
|
||||
| hideRequiredMark | 隐藏所有表单项的必选标记 | boolean | false | |
|
||||
| initialValues | 表单默认值,只有初始化以及重置时生效 | object | - | |
|
||||
| labelAlign | label 标签的文本对齐方式 | `left` \| `right` | `right` | |
|
||||
| labelCol | label 标签布局,同 `<Col>` 组件,设置 `span` `offset` 值,如 `{span: 3, offset: 12}` 或 `sm: {span: 3, offset: 12}` | [object](/components/grid/#Col) | - | |
|
||||
| layout | 表单布局 | `horizontal` \| `vertical` \| `inline` | `horizontal` | |
|
||||
| name | 表单名称,会作为表单字段 `id` 前缀使用 | string | - | |
|
||||
| scrollToFirstError | 提交失败自动滚动到第一个错误字段 | false | - | |
|
||||
| size | 设置字段组件的尺寸(仅限 antd 组件) | `small` \| `middle` \| `large` | - | |
|
||||
| validateMessages | 验证提示模板,说明[见下](#validateMessages) | [ValidateMessages](https://github.com/react-component/field-form/blob/master/src/utils/messages.ts) | - | |
|
||||
| validateTrigger | 统一设置字段校验规则 | string \| string[] | 'onChange' | 4.3.0 |
|
||||
| wrapperCol | 需要为输入控件设置布局样式时,使用该属性,用法同 labelCol | [object](/components/grid/#Col) | - | |
|
||||
| onFinish | 提交表单且数据验证成功后回调事件 | Function(values) | - | |
|
||||
| onFinishFailed | 提交表单且数据验证失败后回调事件 | Function({ values, errorFields, outOfDate }) | - | |
|
||||
| onFieldsChange | 字段更新时触发回调事件 | Function(changedFields, allFields) | - | |
|
||||
| onValuesChange | 字段值更新时触发回调事件 | Function(changedValues, allValues) | - | |
|
||||
|
||||
### validateMessages
|
||||
|
||||
|
@ -119,7 +119,7 @@
|
||||
"rc-dialog": "~7.7.0",
|
||||
"rc-drawer": "~3.2.0",
|
||||
"rc-dropdown": "~3.0.0",
|
||||
"rc-field-form": "~1.2.0",
|
||||
"rc-field-form": "~1.3.0",
|
||||
"rc-input-number": "~4.6.1",
|
||||
"rc-mentions": "~1.1.0",
|
||||
"rc-menu": "~8.1.0",
|
||||
|
Loading…
Reference in New Issue
Block a user