Jump to:

23376 Posts in 18237 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Currency format 10,000.00 to 10.000,00

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

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

Page: 1
Go to End
Author Topic: 4383 Views
  • PeterNL
    Avatar
    Community Member
    9 Posts

    Currency format 10,000.00 to 10.000,00 Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: Currency format 10,000.00 to 10.000,00 Link to this post

    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)

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Currency format 10,000.00 to 10.000,00 Link to this post

    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.

  • PeterNL
    Avatar
    Community Member
    9 Posts

    Re: Currency format 10,000.00 to 10.000,00 Link to this post

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

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: Currency format 10,000.00 to 10.000,00 Link to this post

    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.

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Currency format 10,000.00 to 10.000,00 Link to this post

    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?

    4383 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.