function tweet_feed_field_presave in Tweet Feed 7.2
Same name and namespace in other branches
- 7.3 tweet_feed.field_info.inc \tweet_feed_field_presave()
Implements hook_field_presave().
PDO throws an error when attempting to insert an empty string into a float field. Go through all values and convert empty strings to NULL.
File
- ./
tweet_feed.field_info.inc, line 35
Code
function tweet_feed_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
if ($field['type'] === 'tweet_feed_user_mention') {
foreach ($items as $delta => $item) {
if (!empty($item)) {
foreach ($item as $k => $v) {
if ($v === '') {
$item[$k] = NULL;
}
}
$items[$delta] = $item;
}
}
}
}