Browse Source

docs: update docs for form

pull/3777/head
Benjy Cui 8 years ago
parent
commit
4d2bdfd93d
  1. 7
      components/form/index.en-US.md
  2. 6
      components/form/index.zh-CN.md

7
components/form/index.en-US.md

@ -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)
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` and should not add `value` `onChange` to controls. (There are warnings after `antd@2.0`)
2. You can not set default value via `defaultValue` prop, you should use `initialValue` in `getFieldDecorator` instead.
1. You don't need to use `onChange` to collect data, but you still can listen to `onChange`(and so on) events.
2. You can not set value of form control via `value` `defaultValue` prop, and you should set default value with `initialValue` in `getFieldDecorator` instead.
3. You don't need to call `setState` manully, please use `this.props.form.setFieldsValue` to change value programmatically.
#### Special attention

6
components/form/index.zh-CN.md

@ -77,10 +77,10 @@ CustomizedForm = Form.create({})(CustomizedForm);
### this.props.form.getFieldDecorator(id, options)
经过 `getFieldDecorator` 包装的控件,表单控件会自动添加 `value` `onChange` 等属性,数据同步将被 Form 接管,这会导致以下结果:
经过 `getFieldDecorator` 包装的控件,表单控件会自动添加 `value`(或 `valuePropName` 指定的其他属性) `onChange`(或 `trigger` 指定的其他属性),数据同步将被 Form 接管,这会导致以下结果:
1. 你不再需要用 `onChange` 来做同步,也不应该给控件单独添加 `value` `onChange` 等属性。(2.0 后会在控制台进行警告)
2. 你不能用控件的 `defaultValue` 属性来设置默认值,请`getFieldDecorator` 里的 `initialValue`
1. 你不再需要用 `onChange` 来做同步,但还是可以继续监听 `onChange` 等事件。
2. 你不能用控件的 `value` `defaultValue` 等属性来设置表单域的值,默认值可以`getFieldDecorator` 里的 `initialValue`
3. 你不需要用 `setState`,可以使用 `this.props.form.setFieldsValue` 来动态改变表单值。
#### 特别注意

Loading…
Cancel
Save