In Groovy/Grails 2.0 I've got a domain with Float variable ( Float weight = 25.28 for example ). When Grails generates form with corresponding number input field, validation complains about the 25.28 value and will only accept an int value. Could someone illuminate what's going on with that? Thanks in advance.
EDIT: In Gails domain object(Double and BigDecimal for the sake of argument):
Double weight = 350.26;
BigDecimal width = 86.1;
Generated html:
<input id="weight" type="number" value="350.26" required="" name="weight">
<input id="width" type="number" value="86.1" required="" name="width">
... turns our FF 7 is fine with those numeric values and Chrome gives me "Invalid Value" and only accepts integers. Any idea on what I'm missing?
If you're using 'grails generate-all' _form.gsp files then update the generated _form.gsp input element to add step="0.001" or step="0.1" or step="any" or the like.
http://code.google.com/p/chromium/issues/detail?id=44116
One approach to get this update into all generated _form.gsp files is to run 'grails install-templates' then edit src/templates/scaffolding/renderEditor.template renderNumberEditor method and add step="any" to each
Had the same problem. It was solved for me by editing the generated _form.gsp view, as jlpp said, but change the markup of the inputs to this:
<input id="weight" type="number decimal" value="350.26" required="" name="weight">
<input id="width" type="number decimal" value="86.1" required="" name="width">
Note the type="number decimal" to add decimal support on browser validation. More a browser issue than a grails one. Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With