fix form demo

This commit is contained in:
zombiej 2018-11-23 11:25:28 +08:00
parent ed4cc9e5fd
commit e36e5aa5a2

View File

@ -18,6 +18,8 @@ import { Form, Input, Icon, Button } from 'antd';
const FormItem = Form.Item; const FormItem = Form.Item;
let id = 0;
class DynamicFieldSet extends React.Component { class DynamicFieldSet extends React.Component {
remove = (k) => { remove = (k) => {
const { form } = this.props; const { form } = this.props;
@ -37,8 +39,9 @@ class DynamicFieldSet extends React.Component {
add = () => { add = () => {
const { form } = this.props; const { form } = this.props;
// can use data-binding to get // can use data-binding to get
const myId = id++;
const keys = form.getFieldValue('keys'); const keys = form.getFieldValue('keys');
const nextKeys = keys.concat(keys.length); const nextKeys = keys.concat(myId);
// can use data-binding to set // can use data-binding to set
// important! notify form to detect changes // important! notify form to detect changes
form.setFieldsValue({ form.setFieldsValue({