Thursday 18 November 2010 5:46:04 pm - 7 replies
I am using ezfloat for an attribute but it seems to round floating numbers to 2 decimals.
Is this normal ? How to make it store three or more decimals ?
Thanx in advance for any help.
Modified on Thursday 18 November 2010 5:46:43 pm by H-Works Agency
Sunday 21 November 2010 10:43:49 pm
Not really sure, but you might find some related info here: http://issues.ez.no/IssueView.php?Id=15116&activeItem=30
Saturday 27 November 2010 12:35:41 am
I have the exact same problem : I need to store 3 decimals float numbers in many objects, but after saving my object and going back to edit it, I can only see a 2 decimals number.
I checked in the ezcontentobject_attribute table in the mysql database and the value is still stored with 3 decimals. That is at least reassuring.
What embarasses me more is that if I edit my object again (in order to change some other attribute value fo example), my float attribute value is stored with only 2 decimals in the database, if I forget to put the 3 decimals value AGAIN and everytime I wish to edit my object.
I think there is an issue here , so if anyone could tell us if there is a setting somewhere to force the attribute value in back office to show more than 2 decimals, it would be nice.
Sunday 28 November 2010 2:02:49 pm
Yes the good news is that db value isn't rounded.
Rounding must then happen thru a template operator both in front and admin siteaccess.
That would explain why db value is rounded when you resubmit your object form.
I am gonna try to find the solution and will keep you informed.
Wednesday 08 December 2010 4:13:40 pm
The problem is due to the l10n('number') transformation.
To modify number of digits you have two solutions :
- Tedious but clean : Overriding content/datatype/edit/ezfloat.tpl templates and removing "l10n('number')"
- Simpler but dirty : Editing ./share/locales/eng-GB.ini => [Numbers] FractDigits=4 (instead of 2 if you want 4 decimals).
Why dirty ? : In this case you edit an install wide variable. You thus can't override this variable on a per-siteaccess basis (which would be a great feature).
Modified on Wednesday 08 December 2010 4:15:28 pm by H-Works Agency
Thursday 09 December 2010 8:19:25 am
Thanks a lot for the information. I chose the 2nd solution as I also have some calculated float fields which Id' like to show on the website with 3 decimals, and therefore needed to specify somewhere the number of decimals to show when using l10n function.
But it's true that I'd rather override the locale configuration (in my own extension for example, which would be the cleanest way) than edit the install variable.
Anyway, thank you for the solution.
You must be logged in to post messages in this topic!