I have a form which has a field for currency which won’t submit with decimal values. The mysql database fields are decimal (8,2). There’s no error, the field just glows blue. If I remove the decimals it submits. Any pointers would be appreciated. I’ve tried recreating both the server action and the form to no avail.
Another anomaly, with that same field I have to convert it to number to format as currency on output. purchase_price.toNumber().formatCurrency(’$’, ‘.’, ‘,’, 2). If I don’t have the toNumber() it doesn’t output.
If it’s a validation issue, I might have come across a similar problem. I wanted to allow numbers with or without a decimal part, and not allow any commas.
Using a regular expression seemed to be a solution. data-rule-pattern="^(?:\d*\.)?\d+$"
I also made the input type text rather than number.
So which of the inputs are you submitting as a decimal?
Also:
What value are you entering in the form input and what value are you actually sending to the server side?
Which field are you having trouble with specifically?
Additionally, as Teodor is asking - is you could also share a screenshot of the PAYLOD & RESPONSE tabs in the network tab of your browser developer tools - that would be helpful.
I went back and looked at another project that's using a decimal field and the only difference was I had a number validation rule. Tried that on the sale_price and low and behold that also fixes the issue.
It’s an idiosyncrasy of the HTML 5 number input type. It is how we overcome it in the end as faced the same issue some months ago. Is the correct method rather than using validation or JavaScript.
Maybe this could be added to the input type for number in an update @Teodor?