diff --git a/components/form/Form.tsx b/components/form/Form.tsx index b4d664be8c..685e2a9eef 100755 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -84,6 +84,7 @@ export type GetFieldDecoratorOptions = { normalize?: (value: any, prevValue: any, allValues: any) => any; /** Whether stop validate on first rule of error for this field. */ validateFirst?: boolean; + preserve?: boolean; }; // function create diff --git a/components/form/index.en-US.md b/components/form/index.en-US.md index 4a24b8c47c..bafc1b66d3 100644 --- a/components/form/index.en-US.md +++ b/components/form/index.en-US.md @@ -172,6 +172,7 @@ After wrapped by `getFieldDecorator`, `value`(or other property defined by `valu | options.getValueProps | Get the component props according to field value. | function(value): any | [reference](https://github.com/react-component/form#option-object) | options.initialValue | You can specify initial value, type, optional value of children node. (Note: Because `Form` will test equality with `===` internally, we recommend to use variable as `initialValue`, instead of literal) | | n/a | | options.normalize | Normalize value to form component, [a select-all example](https://codepen.io/afc163/pen/JJVXzG?editors=001) | function(value, prevValue, allValues): any | - | +| options.preserve | Keep the field even if field removed | boolean | - | | options.rules | Includes validation rules. Please refer to "Validation Rules" part for details. | object\[] | n/a | | options.trigger | When to collect the value of children node | string | 'onChange' | | options.validateFirst | Whether stop validate on first rule of error for this field. | boolean | false | diff --git a/components/form/index.zh-CN.md b/components/form/index.zh-CN.md index 2a23f05681..b5ac7c78b0 100644 --- a/components/form/index.zh-CN.md +++ b/components/form/index.zh-CN.md @@ -174,6 +174,7 @@ validateFields(['field1', 'field2'], options, (errors, values) => { | options.getValueFromEvent | 可以把 onChange 的参数(如 event)转化为控件的值 | function(..args) | [reference](https://github.com/react-component/form#option-object) | | options.initialValue | 子节点的初始值,类型、可选值均由子节点决定(注意:由于内部校验时使用 `===` 判断是否变化,建议使用变量缓存所需设置的值而非直接使用字面量)) | | | | options.normalize | 转换默认的 value 给控件,[一个选择全部的例子](https://codepen.io/afc163/pen/JJVXzG?editors=001) | function(value, prevValue, allValues): any | - | +| options.preserve | 即便字段不再使用,也保留该字段的值 | boolean | - | | options.rules | 校验规则,参考下方文档 | object\[] | | | options.trigger | 收集子节点的值的时机 | string | 'onChange' | | options.validateFirst | 当某一规则校验不通过时,是否停止剩下的规则的校验 | boolean | false | diff --git a/package.json b/package.json index fd37327498..bbc1865ee2 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "rc-drawer": "~1.7.6", "rc-dropdown": "~2.3.0", "rc-editor-mention": "^1.1.7", - "rc-form": "^2.3.0", + "rc-form": "^2.4.0", "rc-input-number": "~4.3.7", "rc-menu": "~7.4.12", "rc-notification": "~3.3.0",