Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | number.module_2_0.patch | 645 bytes | yched |
number.module_2.patch | 636 bytes | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedSorry, I managed to make a 2 line patch broken.
And the text in my previous post should read :
Comment #2
yched CreditAttribution: yched commentedI committed the patch to both branches, at least as a temporary fix
Comment #3
(not verified) CreditAttribution: commented