Pull merge.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_presave.twig
1 /**
2  * Implements hook_field_presave().
3  */
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
7     // backends.
8     foreach ($items as $delta => $item) {
9       if (isset($item['value'])) {
10         $items[$delta]['value'] = round($item['value'], $field['settings']['scale']);
11       }
12     }
13   }
14 }