Skip to content Skip to sidebar Skip to footer

Save Data From Many Forms Using Getfieldvalue()

I try to save data from 2 form (Main and SubForm) using getFieldValue(). Here should appear both form data: Now i get an empty object when i click save handler. If i remove the &

Solution 1:

You need to define 2 refs, one for each form.

const mainFormRef = useRef();
const subFormRef = useRef();

and set these refs on respective forms

<Formname="main"ref={mainFormRef}....
>
  ....
</Form><SubFormmyRef={subFormRef} />

finally, inside save function, call getFieldValue on both refs

constsave = () => {
    console.log(mainFormRef.current.getFieldValue());
    console.log(subFormRef.current.getFieldValue());
};

Post a Comment for "Save Data From Many Forms Using Getfieldvalue()"