mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-19 06:43:16 +08:00
docs: update docs for form
This commit is contained in:
parent
a91a7208a6
commit
4d2bdfd93d
@ -75,11 +75,10 @@ If the form has been decorated by `Form.create` then it has `this.props.form` pr
|
|||||||
|
|
||||||
### this.props.form.getFieldDecorator(id, options)
|
### this.props.form.getFieldDecorator(id, options)
|
||||||
|
|
||||||
After wrapped by `getFieldDecorator`, `value` `onChange` props will be added to form controls,the flow of form data will be handled by Form which will cause:
|
After wrapped by `getFieldDecorator`, `value`(or other property defined by `valuePropName`) `onChange`(or other property defined by `trigger`) props will be added to form controls,the flow of form data will be handled by Form which will cause:
|
||||||
|
|
||||||
|
1. You don't need to use `onChange` to collect data, but you still can listen to `onChange`(and so on) events.
|
||||||
1. You don't need to use `onChange` and should not add `value` `onChange` to controls. (There are warnings after `antd@2.0`)
|
2. You can not set value of form control via `value` `defaultValue` prop, and you should set default value with `initialValue` in `getFieldDecorator` instead.
|
||||||
2. You can not set default value via `defaultValue` prop, you should use `initialValue` in `getFieldDecorator` instead.
|
|
||||||
3. You don't need to call `setState` manully, please use `this.props.form.setFieldsValue` to change value programmatically.
|
3. You don't need to call `setState` manully, please use `this.props.form.setFieldsValue` to change value programmatically.
|
||||||
|
|
||||||
#### Special attention
|
#### Special attention
|
||||||
|
@ -77,10 +77,10 @@ CustomizedForm = Form.create({})(CustomizedForm);
|
|||||||
|
|
||||||
### this.props.form.getFieldDecorator(id, options)
|
### this.props.form.getFieldDecorator(id, options)
|
||||||
|
|
||||||
经过 `getFieldDecorator` 包装的控件,表单控件会自动添加 `value` `onChange` 等属性,数据同步将被 Form 接管,这会导致以下结果:
|
经过 `getFieldDecorator` 包装的控件,表单控件会自动添加 `value`(或 `valuePropName` 指定的其他属性) `onChange`(或 `trigger` 指定的其他属性),数据同步将被 Form 接管,这会导致以下结果:
|
||||||
|
|
||||||
1. 你不再需要用 `onChange` 来做同步,也不应该给控件单独添加 `value` `onChange` 等属性。(2.0 后会在控制台进行警告)
|
1. 你不再需要用 `onChange` 来做同步,但还是可以继续监听 `onChange` 等事件。
|
||||||
2. 你不能用控件的 `defaultValue` 属性来设置默认值,请用 `getFieldDecorator` 里的 `initialValue`。
|
2. 你不能用控件的 `value` `defaultValue` 等属性来设置表单域的值,默认值可以用 `getFieldDecorator` 里的 `initialValue`。
|
||||||
3. 你不需要用 `setState`,可以使用 `this.props.form.setFieldsValue` 来动态改变表单值。
|
3. 你不需要用 `setState`,可以使用 `this.props.form.setFieldsValue` 来动态改变表单值。
|
||||||
|
|
||||||
#### 特别注意
|
#### 特别注意
|
||||||
|
Loading…
Reference in New Issue
Block a user