forge42dev / remix-hook-form

Open source wrapper for react-hook-form aimed at Remix.run
MIT License
330 stars 27 forks source link

Form submit data on handleSubmit #96

Closed viganzeqiri closed 2 months ago

viganzeqiri commented 3 months ago

Hey there :) I have a form that could be submitted by two buttons, one button saves the data in server, and the other one saves and also changes the status. I send an intent inside submitData to determine which action to run, the save one has a save intent, while the other has saveAndMoveToPending. I wanted to know if its possible to pass the intent to the handleSubmit function based on the button I am clicking and not in the form config

AlemTuzlak commented 3 months ago

I think if you set the values before submission it would work, but not as clean as it could be, eg:

onClick={() => {
  setValue(intent); 
  handleSubmit();
}}
viganzeqiri commented 3 months ago

I think if you set the values before submission it would work, but not as clean as it could be, eg:

onClick={() => {
  setValue(intent); 
  handleSubmit();
}}

Thanks a lot for your answer :) I will give this a try, but yeah I was hoping for something cleaner 😅

AlemTuzlak commented 3 months ago

The unfortunate thing is that the submission is kind of "controlled" via teh handleSubmit so theres no way to pass values in an uncontrolled manner