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

[FORMS] Invalid form causes NumericField with localised number format to be populated in wrong format after validation #6910

Closed
sb-relaxt-at opened this issue May 12, 2017 · 6 comments

Comments

@sb-relaxt-at
Copy link
Contributor

sb-relaxt-at commented May 12, 2017

If a form validation fails, the form is populated with the submitted values. The submitted values are determined by calling the getData method. This method iterates over all data fields and determines their value by calling dataValue. The NumericField returns as dataValue the normalised format of its value (e.g. '4.2'). The type of the returned value is a string (as defined in the PHPDocs). When loading this value into the form in setupFormErrors, the setValue method in NumericField gets passed the normalised value as string as well as the array of all submitted data. As the value is neither of type int or float, nor is the data passed as second argument a DataObject, the non localised value is set. This results in NumericFields, where all values are non localised. Saving the form again results in a form validation error, as the non-localised values are not valid.

This is a 3.5.x issue.

@dhensby
Copy link
Contributor

dhensby commented May 12, 2017

see #6911 for fix

@sb-relaxt-at
Copy link
Contributor Author

That was fast :-) Thanks a lot, I added some comments to #6911

@tractorcow
Copy link
Contributor

We could fix this by making the session errors data array hold the submitted value, rather than the data value. It needs a bit more investigation.

@sminnee sminnee changed the title Invalid form causes NumericField with localised number format to be populated in wrong format after validation [FORMS] Invalid form causes NumericField with localised number format to be populated in wrong format after validation Oct 6, 2018
@intwebg
Copy link

intwebg commented Nov 28, 2018

I notice a related problem when i'm trying to add 1000 inside the NumericField. On submission, 1000become 1 000(with a space). If I save again I receive a validation error message. I must remove the space the be able to save it again... I use SS 4.2.2

@GuySartorelli
Copy link
Member

Changing to impact medium (we have a lot of international uses of Silverstripe out there).

@GuySartorelli
Copy link
Member

Closed in favour of #10626

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants