function countries_field_prepare_view in Countries 7.2
Same name and namespace in other branches
- 8 countries.fields.inc \countries_field_prepare_view()
Implements hook_field_prepare_view().
File
- ./
countries.fields.inc, line 53 - All field related code.
Code
function countries_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
foreach ($entities as $id => $entity) {
foreach ($items[$id] as $delta => $item) {
if (!isset($item['country'])) {
$items[$id][$delta]['value'] = $item['iso2'];
if (!empty($item['iso2']) && ($country = country_load($item['iso2']))) {
$items[$id][$delta]['country'] = $country;
$items[$id][$delta]['safe_value'] = check_plain($items[$id][$delta]['country']->name);
}
else {
$items[$id][$delta]['country'] = FALSE;
$items[$id][$delta]['safe_value'] = '';
}
// @todo: Remove post 7.x-2.x
$items[$id][$delta]['safe'] = $items[$id][$delta]['safe_value'];
}
}
}
}