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

Numbers with comma as decimal will save the number as string with the comma #4

Closed
12 of 17 tasks
bpanatta opened this issue Jun 7, 2018 · 0 comments
Closed
12 of 17 tasks
Labels
bug Something isn't working

Comments

@bpanatta
Copy link

bpanatta commented Jun 7, 2018

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of yii2-number.
  • This is not an usage question. I confirm having gone through and read the documentation and demos.
  • This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional).

Steps to reproduce the issue

The best way to reproduce is searching the NumberControl demo for "German Amount" and changing the input value, this will give the same result as in my code.
Still, here is how to get there by coding:

  1. Create a NumberControl widget inside a form with 'radixPoint' => ','
echo NumberControl::widget([
    'name' => 'amount_german',
    'value' => 78232.01,
    'maskedInputOptions' => [
        'groupSeparator' => '.',
        'radixPoint' => ','
    ],
]);
  1. Change the default value and submit the form.
  2. Check the submitted data.

Expected behavior and actual behavior

When I follow those steps, I see the number as a string with the comma as the decimal separator, i.e.: "1234,01".

I was expecting to get the number as a number, having decimals separated by a dot, i.e.: 1234.01.
Since the initial value passed to the widget is a number with dot as decimal separator, I expect to receive a number with a dot as decimal separator from the widget. Thus, keeping the data integrity.

Environment

Browsers

  • Google Chrome
  • Mozilla Firefox
  • Internet Explorer
  • Safari

Operating System

  • Windows
  • Mac OS X
  • Linux
  • Mobile

Libraries

  • jQuery version: 3.2.1
  • yii2-number version: 1.0.1

Isolating the problem

  • This bug happens on the docs and demos page
  • The bug happens consistently across all tested browsers
  • This bug happens when using yii2-number without other plugins.
@kartik-v kartik-v added the bug Something isn't working label Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants