You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use top-level disabled prop on useForm to disable forms #1895
#1893 handles instance create, which is the worst offender because the POST takes a long time to come back. But strictly speaking, every other form has the same problem. We could manually wire up every form with disabled props on every field, like in #1893, but it would probably be better if we could find a more automatic way.
Someone asked about this here but didn't get an answer:
RHF recently (in v7.48.0) added a way to pass disabled to useForm, and then it might automatically get passed into all registered fields. Worth exploring!
Not sure why we didn't think of this before, but it seems clear from their examples (PR, release) that the way you're supposed to do this is have a disabled state variable and call setState on it to change the form's disabled state.
So the above business about calling _disableForm shouldn't be necessary if can control disabled wherever we call useForm and pass the setDisabled around wherever we need to.
Activity
charliepark commentedon Feb 1, 2024
Crespo and I looked at this a bit today, and determined that — once we upgrade RHF — this should work in SideModalForm:
_disableFormis currently undocumented, so Crespo also asked the RHF team directly about future plans for it: https://github.com/orgs/react-hook-form/discussions/11462[-]Disable forms while submitting[/-][+]Use top-level `disabled` prop on `useForm` to disable forms[/+]david-crespo commentedon Mar 6, 2024
Not sure why we didn't think of this before, but it seems clear from their examples (PR, release) that the way you're supposed to do this is have a
disabledstate variable and callsetStateon it to change the form's disabled state.So the above business about calling
_disableFormshouldn't be necessary if can controldisabledwherever we calluseFormand pass thesetDisabledaround wherever we need to.