The new advanced formatters for number field display '0' for an empty field.
This is because format_number(NULL) == '0'

Attached is a quick fix for this, but I'm not sure it's quite normal that the formatter gets called with a NULL value to begin with.

NULL is the default db value for number fields, and thus on node load we have
$node->field_my_number == array([0] => NULL)
which is normal in a way, but can be surprising.

CommentFileSizeAuthor
#1 number.module_2_0.patch645 bytesyched
number.module_2.patch636 bytesyched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

FileSize
645 bytes

Sorry, I managed to make a 2 line patch broken.

And the text in my previous post should read :

$node->field_my_number == array(
[0] => Array('value' => NULL),
)
yched’s picture

Status: Needs review » Fixed

I committed the patch to both branches, at least as a temporary fix

Anonymous’s picture

Status: Fixed » Closed (fixed)