react-final-form icon indicating copy to clipboard operation
react-final-form copied to clipboard

OnSubmit doesn't work

Open Maxim1saev opened this issue 3 years ago • 4 comments

image

Hello! We use "final-form": "4.20.2", the submission stopped working when it was passed to the rff component you have to explicitly transfer the handler to onclick

image

Previously, everything worked correctly

Thanks in advance!)

Maxim1saev avatar May 27 '21 13:05 Maxim1saev

I believe you need to explicitly set the form's onSubmit to the FinalFormRenderProps handleSubmit value. Notice how the example from the react-final-form docs sets the form element's onSubmit from the render props:

<Form onSubmit={onSubmit}>
  {props => (
    <form onSubmit={props.handleSubmit}>

      ... fields go here...

      <button type="submit">Submit</button>
    </form>
  )}
</Form>

Once that value is set the form should submit properly. You'll also want to make sure that the button element you're using to trigger the form has a type of "submit".

tjb042 avatar May 28 '21 15:05 tjb042

@tjb042 it is your version that does not work

Maxim1saev avatar Jun 01 '21 19:06 Maxim1saev

I made a sandbox with an example, and it seems to work fine. @Maxim1905 can you provide a minimal reproducible sandbox or repo with the error you are facing? It's hard to say what might be wrong without seeing more code.

BATCOH avatar Jun 01 '21 23:06 BATCOH

Looks like your button is in the footer portion of a modal. That means it may not be nested so it may need to follow external submit pattern or make use of FormSpy. It would be better to give a complete example than screenshots as you're leaving a lot to the imagination.

bluSCALE4 avatar Sep 22 '21 22:09 bluSCALE4