React Ant Design Form: Adding New Rows and Rendering Input Values
It seems like there is a problem with the rendering of the input values when adding a new row in the form.
To fix this issue, you can update the 'add' method in the 'UpdateForm' component as follows:
add = () => {
const { form } = this.props;
const list = form.getFieldValue('list');
const nextList = list ? [...list, {}] : [{}];
form.setFieldsValue({
list: nextList,
});
form.validateFields(); // Add this line to update the form fields with the new values
}
By calling 'form.validateFields()' after adding a new row, it will update the form fields with the new values and ensure that they are rendered correctly when opening the modal again.
原文地址: https://www.cveoy.top/t/topic/qkZj 著作权归作者所有。请勿转载和采集!