Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use `step="any"` on non-integer numeric inputs or those with a scale …

…>= 7

This fixes 2 things:

1. If a floating point numeric property has no `scale` constraint then the scaffolded input would have no `step` attribute meaning Webkit browsers prevent input of decimal data.

2. If the field has a `scale` constraint >= 7 then the `step` attribute was being set to an invalid value.

Fixes GRAILS-8463
  • Loading branch information...
commit 1e47c4ec44b9f540ed76914a720bb256cb260188 1 parent a266a8a
Rob Fletcher authored
View
3  grails-resources/src/grails/templates/scaffolding/renderEditor.template
@@ -174,7 +174,8 @@
sb << '/>'
} else {
sb << '<g:field type="number" name="' << property.name << '"'
- if (cp.scale != null) sb << ' step="' << BigDecimal.valueOf(1).movePointLeft(cp.scale).toString() << '"'
+ if (cp.scale != null && cp.scale < 7) sb << ' step="' << BigDecimal.valueOf(1).movePointLeft(cp.scale).toString() << '"'
+ else if (property.type in [float, double, Float, Double, BigDecimal]) sb << ' step="any"'
if (cp.min != null) sb << ' min="' << cp.min << '"'
if (cp.max != null) sb << ' max="' << cp.max << '"'
if (isRequired()) sb << ' required=""'
Please sign in to comment.
Something went wrong with that request. Please try again.