How can I allow null form values but non-null submission values? (Typescript, MUI, Controller, Autocomplete) #9332
Replies: 5 comments 6 replies
-
Could you please explain more details what problem you got with the codesandbox url ? |
Beta Was this translation helpful? Give feedback.
-
@tomashaddad You can use "onError" callback of method |
Beta Was this translation helpful? Give feedback.
-
Hello, I have the same problem. Here is a simple code to demonstrate it.
|
Beta Was this translation helpful? Give feedback.
-
Late to the party I guess but for what it's worth, useForm nowadays supports passing a TTransformedValues generic:
|
Beta Was this translation helpful? Give feedback.
-
Hello @tomashaddad , did you find a good solution for this case? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Firstly, thank you a lot for this package!
I've searched around a bit for this but I'm still not sure how to do it properly. Take this example with two codependent MUI
Autocomplete
components:https://codesandbox.io/s/elastic-sanne-2cck6p?file=/src/App.tsx
Autocomplete
takes a value ofnull
to display no item. This is the default behaviour I want since this data will come from a server. Submission of this form is not possible without both fields, but the submit function expects the type of the submission to match the type of the form.So if form submission is successful, how can I write a submit function that knows the given values aren't null?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions