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

[Form] Fixed NumberToLocalizedStringTransformer to accept both comma and dot #5941

Merged
merged 1 commit into from Nov 8, 2012

Conversation

webmozart
Copy link
Contributor

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)

fabpot added a commit that referenced this pull request Nov 8, 2012
This PR was merged into the 2.0 branch.

Commits
-------

dc80385 [Form] Fixed NumberToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible

Discussion
----------

[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)
@fabpot fabpot merged commit dc80385 into symfony:2.0 Nov 8, 2012
@LogansUA
Copy link

LogansUA commented Sep 16, 2016

@fabpot Hello. Can you implement same solution for PercentToLocalizedStringTransformer? Because now there is a problem with saving value in de locale.

The problem is that i can't save value with dot (on de locale), i.e. 5.4.

@romaricdrigon
Copy link
Contributor

I confirm the bug is still there in PercentToLocalizedStringTransformer as of Symfony 3.2.7 :(

fabpot added a commit that referenced this pull request Oct 1, 2017
… both comma and dot as decimal separator, if possible (aaa2000)

This PR was squashed before being merged into the 2.7 branch (closes #22586).

Discussion
----------

[Form] Fixed PercentToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible

| Q             | A
| ------------- | ---
| Branch?       | 2.7 <!-- see comment below -->
| Bug fix?      | yes-ish
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | <!-- #-prefixed issue number(s), if any -->
| License       | MIT

<!--
- Bug fixes must be submitted against the lowest branch where they apply
  (lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->

Implements the same behaviour that `NumberToLocalizedStringTransformer` in order to accept both comma and dot implemented in #5941

Commits
-------

f96a7f8 [Form] Fixed PercentToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants