You are here

function geocoder_widget_get_field_info in Geocoder 7

Find a field instance's or entity property's relevant meta data.

2 calls to geocoder_widget_get_field_info()
geocoder_widget_get_entity_field_value in ./geocoder.widget.inc
Return the value for the given proxy-field for the given entity.
geocoder_widget_get_field_value in ./geocoder.widget.inc
Get a field's value based on geocoded data.

File

./geocoder.widget.inc, line 328
geocoder.widget.inc

Code

function geocoder_widget_get_field_info($entity_type, $field_instance, $entity) {
  $entity_info = entity_get_info($entity_type);
  $field_name = is_array($field_instance['widget']['settings']['geocoder_field']) ? reset($field_instance['widget']['settings']['geocoder_field']) : $field_instance['widget']['settings']['geocoder_field'];

  // Determine the source type, if it's a entity-key, we mock it as a "text"
  // field.
  if (in_array($field_name, $entity_info['entity keys'], TRUE) && $entity) {
    $field_info = array(
      'type' => 'text',
      'entity_key' => TRUE,
    );
  }
  else {
    $field_info = field_info_field($field_name);
    if (!$field_info) {
      $info = entity_get_all_property_info($entity_type);
      $field_info = $info[$field_name];
    }
    $field_info['entity_key'] = FALSE;
  }
  return $field_info;
}