You are here

function getlocations_fields_field_insert in Get Locations 7.2

Same name and namespace in other branches
  1. 7 modules/getlocations_fields/getlocations_fields.module \getlocations_fields_field_insert()

Implements hook_field_insert(). Define custom insert behavior for this module's field types.

Parameters

$entity_type: The type of $entity.

$entity: The entity for the operation.

$field: The field structure for the operation.

$instance: The instance structure for $field on $entity's bundle.

$langcode: The language associated with $items.

$items: $entity->{$field['field_name']}[$langcode], or an empty array if unset.

File

modules/getlocations_fields/getlocations_fields.module, line 209
getlocations_fields.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_fields_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
  $settings = FALSE;
  if (isset($field['settings'])) {
    $settings = $field['settings'];
  }
  $settings['display_settings'] = getlocations_fields_get_display_settings($instance['display']['default']['settings']);
  if (!empty($items)) {
    foreach ($items as $key => $item) {
      if (empty($item['latitude']) || empty($item['longitude'])) {
        unset($items[$key]);
      }
    }
    $criteria = array();
    if ($field['field_name']) {
      $criteria = array(
        'field_name' => $field['field_name'],
      );
    }
    if (!empty($criteria)) {
      $items = getlocations_fields_save_locations($items, $criteria, $settings, 'insert');
    }
  }
}