function field_hidden_field_presave in Field Hidden 7
Allows for item value transformations right before the item value (from a submitted for) is being saved in the database.
Rounds decimal items.
Implements hook_field_presave().
Parameters
string $entity_type:
string $entity:
array $field:
array $instance:
string $langcode:
array &$items:
Return value
void
File
- ./
field_hidden.module, line 553 - Drupal Field Hidden module
Code
function field_hidden_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
if ($field['type'] == 'field_hidden_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']);
}
}
}
}