Number module applies a maxlength to the number field widget. This maxlength is set equal to the field's precision. However, the maxlength should actually be two characters larger than the precision: one extra character to support signed values (i.e. negative sign) and one extra character for the decimal separator.

This will also need a test.

CommentFileSizeAuthor
#1 950134-decimal.patch4.26 KBmfb
decimal.patch1.23 KBmfb
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mfb’s picture

FileSize
4.26 KB

Add a test. This test fails without the patch and (hopefully) passes with the patch.

bleen’s picture

should we also add s couple of negative tests? for example, if scale = 4, then 1.23456 should fail.

mfb’s picture

This is obviously a bare minimum of tests. FYI if you exceed the scale it doesn't fail per se It just doesn't store the extra decimals.

yched’s picture

Status: Needs review » Reviewed & tested by the community

This looks good.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome, thanks!

Committed to HEAD.

Status: Fixed » Closed (fixed)

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