symfony/symfony — pull request #5941 by bschussek (2012-11-08 14:51:06+00:00)
Title: [Form] Fixed NumberToLocalizedStringTransformer to accept both comma and dot

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2059
Todo: -
License of the code: MIT
Documentation PR: -

The behaviour after this is as follows:

* if "grouping" (thousands separators) is disabled (the default)
* you may use comma and dot as decimal separator in all locales
* if "grouping" is enabled
* you may use a comma as decimal separator in all locales where the thousands separator is not a comma (e.g. "de", "fr", but not "en")
* you may use a dot as decimal separator in all locales where the thousands separator is not a dot (e.g. "en", "fr", but not "de")

If the form is displayed again, all numbers are displayed in your locale, regardless of which decimal separator you used for input.

**Example 1 (locale "fr"):**

* you enter: "1234.56"
* after submission:
* without grouping: "1234,56"
* with grouping: "1 234,56"

**Example 2 (locale "en"):**

* you enter "1234,56"
* after submission:
* without grouping: "1234.56"
* with grouping: error (because "," is the thousands separator; "1234,560" would have been accepted)