You are here

function range_field_presave in Range 7

Implements hook_field_presave().

File

./range.module, line 229
Defines range field types.

Code

function range_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  if ($field['type'] === 'range_decimal') {

    // Let PHP round the value to ensure consistent behavior across storage
    // backends.
    foreach ($items as $delta => $item) {
      if (isset($item['from'])) {
        $items[$delta]['from'] = round($item['from'], $field['settings']['scale']);
      }
      if (isset($item['to'])) {
        $items[$delta]['to'] = round($item['to'], $field['settings']['scale']);
      }
    }
  }
}