EllisLab text mark
Advanced Search
     
Custom field decimal with comma
Posted: 01 May 2012 03:13 AM   [ Ignore ]
Joined: 2008-01-04
18 posts

Hello,

I want to add a custom field for a price. However EE wants me to use a dot as a decimal separator instead of the comma in Euro prices. I’ve found some other topics, but neither of them is solved.
Is it already possible to change the dot to a comma? Or is there a way to work around this? I really need a comma, because it’s the common way to enter prices in Europe, my site visitor won’t get it if they get an error because they typed a comma.

The field needs the have a value with 2 decimals and needs to be sorted asc/desc.

Thanks

 
Posted: 01 May 2012 03:53 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi Mbruijn,

Let’s see if we can get you sorted out here!

I appreciate your frustration on this, and I tried a few things to get around this. The only thing I found was a fiedtype add-on for currencies.

I don’t see why we aren’t accounting for this already, it sounds worthy of a Feature Request.

Is there anything else I can assist you with?

Cheers,

 Signature 

How may I help you?

 
Posted: 02 May 2012 02:10 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2008-01-04
18 posts

Hi Dan,

Thank you for your reply. I’ve already stumbled upon the currency add-on, but I think it will not solve the problem. It handles converting currencies and has some possebilities to style the way the value is shown (€ in front or behind, etc). As far as I can see on their website it also uses a dot instead of a comma.
I think this ‘problem’ also has to do with the way the MySQL DB handles integers/numbers. MySQL also uses dots as default. I think EE has to modify this output somehow. Correct me if I’m wrong.

Isn’t there a way to solve this with PHP in the template and/or safecracker form?

 
Posted: 02 May 2012 06:13 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi Mbruijn,

The only way I can think around this issue is to make it an “anything goes” text input, rather than a number field.

I tested in the Control Panel publish form, and the validation occurs in the browser, before the form submits.

I think this ‘problem’ also has to do with the way the MySQL DB handles integers/numbers.

I would agree, but ExpressionEngine makes all fields in MySQL “text” for channel field purposes, so technically MySQL shouldn’t care. It’s ExpressionEngine that is trying to validate the data before hand.

Can you tell me the settings you have for this field?

Cheers,

 Signature 

How may I help you?

 
Posted: 04 May 2012 02:20 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2008-01-04
18 posts

Hi Dan,

The settings for the pricefield are:

Type: textinput
Formatting: none
Fieldcontent: decimal

I just bought CartThrob and there’s an option in the CP to adjust the prices with decimalseparator, decimalprecision, thousandsseparator, currency prefix, decimals rounding. I don’t now yet in what kind of format CT saves the data from pricefields.

Because I’ve found an earlier request from 2010, I’ve replied to that one to bump it.

Thanks.

 
Posted: 07 May 2012 03:33 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi Mbruijn,

Excellent. Since CT is engineered to be international, I suspect you will find the flexibility you are looking for.

In the meantime, is there anything else I can assist you with?

Cheers,

 Signature 

How may I help you?

 
Posted: 13 July 2012 04:16 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2010-10-17
181 posts

I just found this price plugin while searching for a solution to the same problem. Works like a charm!

Just put your price field into the tag like this:

{exp:price_format price="{price}"
 
Posted: 16 July 2012 10:55 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2011-11-25
7174 posts

Hey there Heiko,

Thanks for the tip and the link!

If you guys need anything else, please let us know by opening a new thread.

Cheers,

 Signature 

Recent version: EE 2.5.4 | Forum Module 3.1.10 | MSM 2.1.4 | 2.x Bug Tracker | Version Upgrade