Skip to content

Commit ad0325a

Browse files
committed
docs: form add preserve
1 parent 19effd0 commit ad0325a

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

components/form/demo/dynamic-form-item.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let id = 0;
5858
export default {
5959
beforeCreate () {
6060
this.form = this.$form.createForm(this);
61-
this.form.getFieldDecorator('keys', { initialValue: [] });
61+
this.form.getFieldDecorator('keys', { initialValue: [], preserve: true });
6262
},
6363
data () {
6464
return {

components/form/index.en-US.md

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ After wrapped by `getFieldDecorator` or `v-decorator`, `value`(or other property
154154
| options.getValueProps | Get the component props according to field value. | function(value): any | [reference](https://github.com/react-component/form#option-object)
155155
| 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 |
156156
| options.normalize | Normalize value to form component, [a select-all example](https://codesandbox.io/s/kw4l2vqqmv) | function(value, prevValue, allValues): any | - |
157+
| options.preserve | Keep the field even if field removed | boolean | false |
157158
| options.rules | Includes validation rules. Please refer to "Validation Rules" part for details. | object\[] | n/a |
158159
| options.trigger | When to collect the value of children node | string | 'change' |
159160
| options.validateFirst | Whether stop validate on first rule of error for this field. | boolean | false |

components/form/index.zh-CN.md

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ validateFields(['field1', 'field2'], options, (errors, values) => {
152152
| options.getValueFromEvent | 可以把 onChange 的参数(如 event)转化为控件的值 | function(..args) | [reference](https://github.com/react-component/form#option-object) |
153153
| options.initialValue | 子节点的初始值,类型、可选值均由子节点决定(注意:由于内部校验时使用 `===` 判断是否变化,建议使用变量缓存所需设置的值而非直接使用字面量)) | | |
154154
| options.normalize | 转换默认的 value 给控件,[一个选择全部的例子](https://codesandbox.io/s/kw4l2vqqmv) | function(value, prevValue, allValues): any | - |
155+
| options.preserve | 即便字段不再使用,也保留该字段的值 | boolean | false |
155156
| options.rules | 校验规则,参考下方文档 | object\[] | |
156157
| options.trigger | 收集子节点的值的时机 | string | 'change' |
157158
| options.validateFirst | 当某一规则校验不通过时,是否停止剩下的规则的校验 | boolean | false |

types/form/form.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ declare interface FieldDecoratorOptions {
143143
*/
144144
normalize?: (value: any, prevValue: any, allValues: any) => any;
145145

146+
/**
147+
* Keep the field even if field removed
148+
* @default false
149+
* @type boolean
150+
*/
151+
preserve?: boolean;
152+
146153
/**
147154
* Includes validation rules. Please refer to "Validation Rules" part for details.
148155
* @default n/a

0 commit comments

Comments
 (0)