Groovy / Grails浮点值和HTML5数字输入 [英] Groovy/Grails Float value and HTML5 number input
问题描述
提前致谢。
编辑:
在Gails域对象(Double和BigDecimal为了参数):
双重重量= 350.26;
BigDecimal width = 86.1;
生成的html:
< input id =weighttype =numbervalue =350.26required =name =weight>
< input id =widthtype =numbervalue =86.1required =name =width>
...将我们的FF 7与这些数值进行比较,Chrome会给我无效值并只接受整数。
关于我缺少的任何想法?
如果您使用'grails generate-all'_form .gsp文件,然后更新生成的_form.gsp输入元素以添加step =0.001或step =0.1或step =any或类似内容。
http://code.google.com/p/chromium/issues/detail?id=44116获取此更新到所有生成的_form.gsp文件的一种方法是运行'grails install-templates',然后编辑src / templates / scaffolding / renderEditor。模板renderNumberEditor方法并将step =any添加到每个
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
这篇关于Groovy / Grails浮点值和HTML5数字输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!