function formatted_number_field_presave in Formatted Number 7
Implements hook_field_presave().
File
- ./
formatted_number.module, line 240 - Defines numeric field types where the thousand and decimal separators are inherited from the Format Number API module.
Code
function formatted_number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
if ($field['type'] == 'formatted_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']);
}
}
}
}