Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numeric field editing broken #317

Open
xpusostomos opened this issue Oct 30, 2021 · 3 comments
Open

numeric field editing broken #317

xpusostomos opened this issue Oct 30, 2021 · 3 comments
Labels
bug help wanted Please submit pull-request

Comments

@xpusostomos
Copy link

xpusostomos commented Oct 30, 2021

If I have a field in my domain class:

Long myField

and that field has a value of 1000000. It ends up generating this HTML:

<input type="number" name="weighting" value="1,000,000" required="" id="myField" />

Those commas mean that the value is never seen because html numeric fields don't like commas.

Tracing the code, this comes from FormFieldsTagLib.groovy line 729:

attrs.value = numberFormatter.format(propertyAccessor.value)

As far as I can see, there should never be locale specific formatting for input fields. Display fields... maybe. But not input fields.

Furthermore, if the type of the field is float or big decimal, the input field looks like this:

<input type="number decimal" name="depreciationRate" value="" id="depreciationRate" />

as far as I know "number decimal" is completely invalid html. Furthermore, if you put a constraint on the field of say min: 0.0 it will generate this:

<input type="number decimal" name="depreciationRate" value="" min="0.0" id="depreciationRate" />
with a min="0.0" attempting to enforce the minimum. Which doesn't work because the browser falls back to "text" for the invalid "number decimal", and therefore min= is ignored by the browser.

This is all very broken, not a minor bug here!
3.0.0.RC1

@osscontributor
Copy link
Member

osscontributor commented Jun 30, 2022

It ends up generating this HTML:

<input type="number" name="weighting" value="1,000,000" required="" id="myField" />

What is it that ends up generating that HTML?

@chrisbitmead
Copy link

Sorry for the lack of clarity. This is when using the auto generated CRUD views which are presumably part of the form fields plugin.

@sbglasius sbglasius added bug help wanted Please submit pull-request labels Jul 5, 2022
@CJD888
Copy link

CJD888 commented Oct 5, 2022

The problem is in FormFieldsTagLib.groovy renderNumericInput() which added localized number formatting. I guess It should not apply formatting when rendering an edit field somehow.

A quick fix is to disable localized numbering using config grails.plugin.fields.localizeNumbers = false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted Please submit pull-request
Projects
None yet
Development

No branches or pull requests

5 participants