Search code examples
javascriptreactjsformsreact-hooksantd

I want to submit two form data by clicking on create button how can i do so


1

I am trying to Recieve both form data in single click which is create button.


Solution

  • I assume you're using reactjs and know useRef. You can use useRef to reference those two submit buttons from different forms. First you need to create a variable

    const buttonRef = useRef()
    

    Now you have to add ref={buttonRef} to both of those button tags as an attribute. Lastly, you have to add a function that triggers those button clicks. You can add onClick attribute to Create button. You can add this to Create button onClick={() => buttonRef.currentRef.click()}.

    These steps will let you submit two form. But won't merge two form data into one.