Many countries in europe are using the comma for the decimal separator instead of a point. There are already different formatters for different output, but when submitting a number decimal text field, the comma would be filtered out. So I added a additional select option to the field settings, where you can choose whether decimal numbers are separated by comma or point. If the comma is selected as separator, the comma is then replaced by a point for storage.

CommentFileSizeAuthor
number_dec_sep.patch2.01 KBmh86
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dopry’s picture

Is this still an issue should it be bumped to 6.x?

alexanderpas’s picture

Both the comma and the point should be considered as a decimal seperator, with the space as a thousands seperator.

http://en.wikipedia.org/wiki/ISO_31-0#Numbers

See Sect. 3.3 of the Standard text.

  • […]
  • ISO 31-0 (after Amendment 2) specifies that "the decimal sign is either the comma on the line or the point on the line". This follows resolution 10 of the 22nd CGPM, 2003; […]
  • Numbers consisting of long sequences of digits can be made more readable by separating them into groups, preferably groups of three, separated by a small space. For this reason, ISO 31-0 specifies that such groups of digits should never be separated by a comma or point, as these are reserved for use as the decimal sign.
  • For numbers whose magnitude is less than 1, the decimal sign should be preceded by a zero.
  • […]
dopry’s picture

Version: 4.7.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Needs work

This seems like more a localization issue. I'm not sure is any localized input support is available in core for D6, we'll have to check up on it first. I don't think we can blindly replace , with . since it is a common thousands seperator in the US, so the str_replace in this version won't work.

I would also be nice to have the field/widget just be smart enough to figure this out on it's own... Maybe we should look to date.module and it's input formats for inspiration?

Also 4.7.x will not see this patch can we re-roll for HEAD and I'm sure we can backport through versions as necessary.

brmassa’s picture

Status: Needs work » Active

Guys,

the custom decimal marker are already on 6.x, but there is a problem. every time the node is saved, a message is displayed telling about the change from comma to point: "Only numbers and the decimal character (,) are allowed in FIELD. 150,00 was changed to 150.00."

if i keep updating the node, it keep showing the same message over and over again. its very strange.

regards,

massa

alexanderpas’s picture

at least that message has a bug! comma only allowed... changed to point... will give a kind of infinite loop situation...

brmassa’s picture

Category: feature » bug

i forgot to set it was a bug

yched’s picture

Status: Active » Fixed

Fixed.

BTW, are there *really* places in the world that would use a whitespace as a comma separator ??

brmassa’s picture

Yves,

good question!

regards,

massa

EDIT: there is no mention on http://en.wikipedia.org/wiki/Decimal_separator. Only comma, dot and "Non-Arabic Numerals"

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

najibx’s picture

Status: Closed (fixed) » Closed (duplicate)

http://drupal.org/node/109246

still not fixed isn't?