How can I display the value of an addressfield in a single line? I modified the "Address form (country-specific)" bundled with the Addressfield module to take only a country, administrative area, and city; this works fine on the node edit form, but when the field is displayed upon viewing the node, it looks like this:



What I want to do is display it on a single line with commas like this:


  Indianapolis, Indiana, United States


I am using the Views module to display the field.  How can I rewrite (using Views or custom code) the addressfield output to be a single line?
I had to do the same thing a couple of days ago, this is what I came up with using hook_field_formatter_info() and hook_field_formatter_view():

function MYMODULE_field_formatter_info() {
  return array(
    'inline_address_field' =&gt; array(
      'label' =&gt; t('Inline Address Field'),
      'field types' =&gt; array('addressfield'),
    )
  );
}


function MYMODULE_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $build = array();

  $count = 1;
  foreach ($items as $item) {
    $inline_address = "&lt;h3&gt;Address $count&lt;/h3&gt;";

    $address_parts = array();
    if (!empty($item['first_name'])) {
      $address_parts[] = $item['first_name'];
    }
    if (!empty($item['last_name'])) {
      $address_parts[] = $item['last_name'];
    }
    if (!empty($item['premise'])) {
      $address_parts[] = $item['premise'];
    }
    if (!empty($item['thoroughfare'])) {
      $address_parts[] = $item['thoroughfare'];
    }
    // And so on for all of the columns that you're interested in, in the order
    // that you want them to be displayed.

    $inline_address .= '&lt;p&gt;' . implode(', ', $address_parts) . '&lt;/p&gt;';

    $build[] = array('#markup' =&gt; $inline_address);
    $count++;
  }

  return $build;
}


It provides a field formatter you can pick for the address field on the node's "Manage Display" form.