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.
number_field_widget_validate() currently does:
// Let PHP round the value to ensure consistent behavior across storage
// backends.
if ($type == 'decimal') {
$value = round($value, $field['settings']['scale']);
}
This has to be done at field level, in hook_field_presave(), so that this applies to programmatic saves as well.
Comment | File | Size | Author |
---|---|---|---|
field_number_round.patch | 2.46 KB | yched | |
Comments
Comment #1
sunPlease note that all new code should use Implements. But since we have to run a global s/Implement/Implements/ anyway, no reason to hold off this patch.
This review is powered by Dreditor.
Comment #2
Dries CreditAttribution: Dries commentedI fixed the implements and committed this patch to CVS HEAD. Thanks!