function mobile_number_field_presave in Mobile Number 7
Implements hook_field_presave().
File
- ./
mobile_number.module, line 175 - mobile_number.module
Code
function mobile_number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach ($items as $delta => $item) {
if (isset($item['value'])) {
try {
$mobile_number = new MobileNumber($item['value']);
$items[$delta]['country'] = $mobile_number->country;
$items[$delta]['local_number'] = $mobile_number->localNumber;
$items[$delta]['tfa'] = !empty($item['tfa']) ? 1 : 0;
} catch (Exception $e) {
unset($items[$delta]);
}
}
}
}