How to format currency in mui input ?

Hi 👋 I have an API which return me prices in cents and i would like to format this value in an iput for editing and after that i would like to submit the modified value in cents. For example the API return me 7200, I would like to display 72.00, to edit 72.00 to 75.99 for example and submit 7599 as modified value to the API. Is there any way to do it with a MUI input or should I display the number input as the user focuses the field, and then switch to displaying a text field as the user clicks outside the field ?
3 Replies
grubby-red
grubby-red2y ago
i look into mui docs. but I haven't seen a comprehensive formatter. they say maybe we can implement in the future https://mui.com/material-ui/react-text-field/#type-quot-number-quot Developing this feature can be done in many ways. you can check this post: https://stackoverflow.com/questions/63150232/react-js-material-ui-how-to-format-textfield-as-an-amount if you need to change data before send to api you can follow this: https://refine.dev/docs/faq/#how-can-i-change-the-form-data-before-submitting-it-to-the-api
optimistic-gold
optimistic-gold2y ago
ok thank you 💪 Have a nice day 😄
grubby-red
grubby-red2y ago
you too 🙏