2 * Implements hook_field_presave().
4 function {{ machine_name }}_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
5 if ($field['type'] == 'number_decimal') {
6 // Let PHP round the value to ensure consistent behavior across storage
8 foreach ($items as $delta => $item) {
9 if (isset($item['value'])) {
10 $items[$delta]['value'] = round($item['value'], $field['settings']['scale']);