remove spaces before submit
Hi everyone !!
I try to modify a phone number to remove space before i send to the API. I get from a mui phone input. I have a state in which i store the phone number. When i submit i have a value like this
+33 6 10 20 30 40
. I have made a function to remove the spaces like following :
which i call in the on finish like this :
i also tried this :
but i always have the same issue which is : edit.tsx:90 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'split')
or replace
in the other case.
My question is : How edit the phone number to remove the spaces before i submit it to the API ?2 Replies
Hi, I am refine support bot :wave:. I am here to help you with your question. I searched for the answer to your question in the refine documentation and found an answer! 🏆
Answer: You can modify the form data before submitting it to the API by using the
Answer: You can modify the form data before submitting it to the API by using the
transformValues
option in the useForm
hook. This option allows you to transform the form values before they are sent to the API.
SOURCES: ./docs/api-reference/mantine/hooks/form/useForm.md, ./docs/faq.md
Note: If this is the answer you need, then we are very lucky. If not, please wait for someone from the refine core team or the community to try to help you.
provincial-silver•2y ago
You can do it the way you write. But you get an error while editing the phone number. I suggest you check it out.