The order of address fields in the node content form need to be configurable. For a US audience, they are more typically:

Thoroughfare
Neighborhood (usually not visible)
SubadminArea (usually not visible)
AdminArea
PostalCode

They cannot be weighted with form_alter, because they are created after it is invoked. This is a problem for form customization in general.

Comments

kcoop’s picture

Oops, that should read:

Thoroughfare
Neighborhood (usually not visible)
Locality
SubadminArea (usually not visible)
AdminArea
PostalCode

xmarket’s picture

Did you try to use the #after_build or #pre_render options of the element?

kcoop’s picture

Title: Add configurable address field order, and/or support form_alter() » Add configurable address field order

No, I'll check those out, thanks. Changing the title to reflect this.

Still, is the current order of fields valid for any region?

xmarket’s picture

Fields are in a general (world-wide), hierarchical order defined by OASIS in xAL.

kcoop’s picture

Interesting. I've never seen an address entered in this way, but I guess I'm showing my US-centricity. :-)

xmarket’s picture

Status: Active » Postponed

Added to the TODO list with a lower priority.

stella’s picture

Yeah entering the fields in this "reverse" order isn't that common, certainly I've never seen it before. Major +1 for reordering the fields, end users are complaining about the usability of these address fields. Not to mention that they don't make sense to Joe Bloggs who just wants to see labels like state, county, street address, etc.

xmarket’s picture

Status: Postponed » Fixed

Added drupal_alter support to address, point and anp elements. See _gmaps_element_alter() in gmaps.module for details.

Example:

function example_gmaps_element_type_gmaps_address_alter(&$element, &$form_state, $form_id, $element_name) {
  //unnecessary to set, because it forced to be the first part
  //$element['country']['#weight'] = 100;
  $element['adminarea']['#weight'] = 98;
  $element['subadminarea']['#weight'] = 97;
  $element['locality']['#weight'] = 96;
  $element['deplocality']['#weight'] = 95;
  $element['thoroughfare']['#weight'] = 94;
  $element['postalcode']['#weight'] = 99;
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.