function number_field_presave

number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items)

Implements hook_field_presave().

File

modules/field/modules/number/number.module, line 157
Defines numeric field types.

Code

function number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($field['type'] == 'number_decimal') {
    // Let PHP round the value to ensure consistent behavior across storage
    // backends.
    foreach ($items as $delta => $item) {
      if (isset($item['value'])) {
        $items[$delta]['value'] = round($item['value'], $field['settings']['scale']);
      }
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!modules!number!number.module/function/number_field_presave/7.x