You are here

function addressfield_views_handler_field_administrative_area::get_value in Address Field 7

Get the value that's supposed to be rendered.

This api exists so that other modules can easy set the values of the field without having the need to change the render method as well.

Parameters

object $values: An object containing all retrieved values.

string $field: Optional name of the field where the value is stored.

Overrides views_handler_field::get_value

File

views/addressfield_views_handler_field_administrative_area.inc, line 31

Class

addressfield_views_handler_field_administrative_area
Defines a field handler that can display the administrative area name instead of the code.

Code

function get_value($values, $field = NULL) {
  $value = parent::get_value($values, $field);

  // If we have a value for the field, look for the administrative area name in the
  // Address Field options list array if specified.
  if (!empty($value) && !empty($this->options['display_name'])) {
    module_load_include('inc', 'addressfield', 'addressfield.administrative_areas');
    $country = $values->{$this->country_alias};
    $areas = addressfield_get_administrative_areas($country);
    if (!empty($areas[$value])) {
      $value = $areas[$value];
    }
  }
  return $value;
}