Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Currency format 10,000.00 to 10.000,00


Go to End


6 Posts   9150 Views

Avatar
PeterNL

Community Member, 9 Posts

17 December 2010 at 10:28pm

Hello all,

I have a problem with the currency, in the netherlands we use 10.000,00 how can i make it that way?

I hope someone could help me, i searched the hole forum.

Thank you

Avatar
swaiba

Forum Moderator, 1899 Posts

18 December 2010 at 2:14am

Hi PeterNL,

As a last resort I'd do...
http://uk.php.net/manual/en/function.number-format.php

But to be able to help more it would be nice to know more informabout how you are storing the data... e.g.

If you are using MoneyField it has setLocale... would this help? (it my also depend on internal php settings)

Avatar
martimiz

Forum Moderator, 1391 Posts

18 December 2010 at 3:04am

Hi

If you're writing your own code, extending the Currency class could also be an option, or you could add a function (custom getter) to your class-that-uses-the-Currency to return the correct format. If it's about some existing module however...

Like Swaiba said, it depends upon what you're trying to do.

Avatar
PeterNL

Community Member, 9 Posts

20 December 2010 at 2:17am

Thanks for your time you both, i now use the TextField and jQuery to count values.

Avatar
swaiba

Forum Moderator, 1899 Posts

20 December 2010 at 3:36am

how are you using jQuery to count values?

are you using this in ModelAdmin, Forms, etc?

I define my money/currency/prices in the DB like this...

'Price'	=> 'Decimal(6,2)',

And currently I don't have a need for this to work outside the UK, but it is coming to Spain and us soon so I will be looking to use translatable dataobject extension and might end up with a CurrencyField or MoneyField.

If you were to create an NLDecimal, by extending Decimal you could override the function 'Nice' to specify the decimal and thousand separator.

Avatar
martimiz

Forum Moderator, 1391 Posts

20 December 2010 at 5:23am

Till now I've always gone for extending the Currency class. It wouldn't be too hard to create something that generates output based on the current locale, would it?

Maybe something that uses localeconv() - unless specified otherwise?