I created a form, and the <TextField /> sends only string, how can I do to send Number ?

I create a model: https://codesandbox.io/s/dropdown-0lscxf?file=/src/pages/posts/CreatePostModal.tsx the form is inside the dropbox "nuova persona".
No description
3 Replies
refine-support-bot
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! 🏆 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.
Answer: You can use the type="number" attribute in the <TextField /> component to send a number. SOURCES: ./docs/api-reference/mui/components/basic-views/edit.md
foreign-sapphire
foreign-sapphire2y ago
Hi @_leonardomuniz, thanks for reproduced code 🙏 you can use this valueAsNumber: true,
{...register('newOrganizzazione.partitaIva', {
required: 'This field is required',
valueAsNumber: true,
})}
{...register('newOrganizzazione.partitaIva', {
required: 'This field is required',
valueAsNumber: true,
})}
you can read more information here: https://react-hook-form.com/api/useform/register/
automatic-azure
automatic-azure2y ago
That was much easier than I thought, thank you very much, including the documentation, I will read it.