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

dot notation instead comma #60

Open
raylight75 opened this issue Aug 28, 2024 · 9 comments
Open

dot notation instead comma #60

raylight75 opened this issue Aug 28, 2024 · 9 comments

Comments

@raylight75
Copy link

Can we use dot notation instead comma 1024,90 === 1024.90

@pelmered
Copy link
Owner

You mean in the the input fields?
I think this should work based on the locale you set for the field.
Can you share some more about what you want to do and what configuration you have for your field?

@raylight75
Copy link
Author

Yes sorry, it depends on the locale, my mistake. I think the default on Windows is a comma so is it possible to replace comma with dot without changing Windows locale.

@AElleray
Copy link

AElleray commented Oct 4, 2024

i have the local for UK GB and in the database my price was saved as. 123.00. and it would ignore the .00. and display the price as 12.3

@saspegas
Copy link

mask working good and showing correctly, but when i click save button it's saving wrong format. i fix it the problem like this:

MoneyInput::make('purchase_price')
  ->label('Alış Fiyatı')
  ->required()
  ->numeric(true)
  ->afterStateHydrated(function (Set $set, $state) {
      $set('purchase_price', number_format($state, 2, ',', '.'));
  })
  ->dehydrateStateUsing(function ($state) {
      return str_replace(['.', ','], ['', '.'], $state);
  }),

The problem is: It's showing and storing masked value, but it must be shown masked and recorded UNMASKED.

@pelmered
Copy link
Owner

mask working good and showing correctly, but when i click save button it's saving wrong format. i fix it the problem like this:

MoneyInput::make('purchase_price')
  ->label('Alış Fiyatı')
  ->required()
  ->numeric(true)
  ->afterStateHydrated(function (Set $set, $state) {
      $set('purchase_price', number_format($state, 2, ',', '.'));
  })
  ->dehydrateStateUsing(function ($state) {
      return str_replace(['.', ','], ['', '.'], $state);
  }),

The problem is: It's showing and storing masked value, but it must be shown masked and recorded UNMASKED.

OK, thank you for this report. I will investigate further. What locale and currency are you using?

@raylight75
Copy link
Author

raylight75 commented Oct 25, 2024

I have the same problem as saspegas said, and I solved it with number_format function too. Just additional information from me

@pelmered
Copy link
Owner

I'm working on a fix for this now.

@pelmered
Copy link
Owner

pelmered commented Nov 8, 2024

As there is a decent work around for this, I will work on this for the coming 2.0 version which will include a partial rewrite of this logic.

@sneycampos
Copy link

sneycampos commented Nov 13, 2024

The problem is: It's showing and storing masked value, but it must be shown masked and recorded UNMASKED.

I don't know what is the solution @pelmered is working but may be a good choice to have a method/flag/anything to "unMaskOnSave" or something else. I'm using same workaround extending the Money Field

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

No branches or pull requests

5 participants