-2

Can somebody help me to get data on submit and delete data of user list Code is available below https://codesandbox.io/s/r4try

the code will help us to add a user but how to delete that user from list ? the Submit button does not return list data so how to return it ?

Please tell me how to delete particular user from the user list. please use delete button on user

Pranshu Saxena
  • 145
  • 1
  • 1
  • 7

1 Answers1

0

You can do this on Form.Provider onFormFinish event. Check form name is 'basicForm' and get users. After that you can clear users list. Example code:

onFormFinish={(name, { values, forms }) => {
      const { basicForm } = forms;
      const users = basicForm.getFieldValue("users") || [];
      if (name === "userForm") {
        basicForm.setFieldsValue({
          users: [...users, values]
        });
        setVisible(false);
      }
      if (name === "basicForm")
      {
        console.log(values.group)
        console.log(users);
        //send data to server or anything else
        basicForm.setFieldsValue({
          users: [],
          group: ""
        });
      } 
    }}
Denis Stukalov
  • 1,236
  • 1
  • 6
  • 11