Last updated 27 August 2012. Created on 2 September 2011.
Edited by firfin, choster, peterx. Log in to edit this page.

The Address Field module provides a Drupal 7 field for standardized storage of postal addresses based on the OASIS xNAL standard.

Address Field provides one or more addresses to an entity, module, or user. It understands the differences in address styles for each country, and offers per-country edit forms and formatting.

For example, for Australia:

City might be the city and, in the case of a big city, is usually the suburb. An address in Wahroonga is usually Wahroonga but might be Wahroonga, Sydney.

We have states: ACT, NSW, NT, QLD, SA, TAS, VIC, and WA. An address in Wahroonga is Wahroonga NSW.

The postal code is usually called postcode and is a four-digit integer with the first digit indicating a state. NSW postcodes start with 2. Sydney is 2000. An address in Wahroonga is Wahroonga NSW 2076.

For a review of the module's inner workings, see the Address Field from a code perspective.

How to use adressfield with tokens / rules see Using tokens with addressfield

Looking for support? Visit the forums, or join #drupal-support in IRC.


schuffr’s picture

Hi all,

I am having a problem migrating address fields. Everything else in my migration works, but address field simply is blank. I have searched for many hours and havent found a definitive answer that works. I am using Drupal 7.37, Migrate 7.x-2.7, Address Field 7.x-1.1. I have set the default value for address to US and I am using the : subfield notation. Any ideas why this wouldn't work?

many thanks!

My migration class is as follows:

    class DOCInfoMigration extends Migration {
      public function __construct($arguments) {
        $this->description = t('Loads early profiles data to DOCInfo profile');
       	/********* Source *********/
       	// MySQL database as source
        $query = Database::getConnection('default', 'default')
                 ->select('DOCInfo', 'u')
                 ->fields('u', array('uid',
        $this->source = new MigrateSourceSQL($query);
    		$this->destination = new MigrateDestinationProfile2('doc_info'); // use machine name of profile
    		/*********** Map **********/
    		// Create a "map" which is used to translate primary keys*/
        $this->map = new MigrateSQLMap($this->machineName,
            'uid' => array(
              'type' => 'int',
              'alias'=> 'u'
        /*********** Connect DOCInfo to user **********/
        $this->addFieldMapping('uid', 'uid');
    #         ->sourceMigration('DOCInfo')  // If user migration class was named 'MyUserMigration', the string is 'MyUser'
    #         ->description(t('The assignment of DOCInfo source data to the respective DOCInfo fields'));
        /******* Field mappings ******/
        /*** Unmapped destination fields ***/
    #                                           'field_address',
peterx’s picture

Hello schuffr, Please open an issue with one of the modules. After the issue is resolved, you can add the solution to this documentation page, if this page needs a change.

tomrenner’s picture

Just a quick explanation how we managed to add Austrian administrative areas with the "new" hooks:

function mymodule_addressfield_address_formats_alter(&$address_formats) {
  $address_formats['AT'] = array(
    'used_fields' => array('locality', 'administrative_area', 'postal_code'),
    'required_fields' => array('locality', 'postal_code'),
    'render_administrative_area_value' => TRUE,
function mymodule_addressfield_administrative_areas_alter(&$administrative_areas) {
  $administrative_areas['AT'] = array(
    'B' => t('Burgenland'),
    'W' => t('Vienna'),
    'NO' => t('Lower Austria'),
    'S' => t('Salzburg'),
    'ST' => t('Steiermark'),
    'OO' => t('Upper Austria'),
    'T' => t('Tyrol'),
    'K' => t('Carinthia'),
    'V' => t('Vorarlberg'),