简体   繁体   中英

Set form text field values after the form submission with ant design in react

I need to change the form text field value after submitting it. I used https://ant.design/components/form/ ant design to create the form.

I have tried the following code inside the form onSubmit method.

this.props.form.setFieldsValue({ count: pasId});

Here count is the getFieldDecorator's id. But the count field value doesn't change to value of pasId variable when I checked as follows.

console.log(values.count);

So where I could get wrong and how to set the form field value after the form values get submitted to the db?

Looks like you need to be using fieldDecorator s, as I can see in the source code for the example for setFieldsValue .

https://ant.design/components/form/#components-form-demo-coordinated

https://github.com/ant-design/ant-design/blob/master/components/form/demo/coordinated.md

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM