The order of fields in the address field input form is not good for certain countries including the UK, as it leads to users inputting their village name in the 'premise' field, which is labelled as 'address 2', the second field on the form. Village should really go in as 'dependent_locality'.

Once this data is recorded it is semantically incorrect, and has repercussions for other modules and display handlers utilizing it.

I'm not sure how to handle this, though, because if, for the UK, we add a dependent_locality field after 'thoroughfare', move the 'premise' field before 'thoroughfare', we'll also end up with users putting thoroughfare in premise and dependent_locality in thoroughfare.

My solution was just to replace premise with dependent_locality, and in cases where a user added a thoroughfare of 'Flat 5, 6 A Street', I would chop of 'Flat 5' programmatically and stick it in the premise variable.

I'm still seeing cases where users put 'Flat 5' into thoroughfare, and '6 Street, A Village' into dependent_locality, though. *sigh* I can see why a lot of sites autofill addresses from postcode / street number.

Thus no patch.

Comments

rszrama’s picture

Component: Code » Address formats
Category: support » feature
Status: Active » Closed (won't fix)

I'm not sure I see anything to be done here. The address fields as given aren't meant to be separated out as you've described. In xNAL the thoroughfare is designed to contain both the street number and name, and the premise is essentially a more specific address indicator that sits beneath the thoroughfare (i.e. apartment number, suite, P.O. box, etc.). We title the premise "Address 2" on the address form, but you can hide that label or disable that form element via hook_form_alter() entirely if you want - it's never required. Unless you actually need to subdivide a city, using the locality for village would work just fine.

If all you really wanted was to separate out the thoroughfare into street number / name, that would be out of scope for this module. We don't have a way to store that data separately anyways, so it would just be taking the two separate fields and combining them together into the single thoroughfare column in the database.

lightsurge’s picture

Just because premise comes after thoroughfare in xNAL doesn't mean it should come after thoroughfare in the addressfield UI for countries where that doesn't make sense.

In the States you might format an address as '26 My Street, Apartment 2, A Town/City, A State, A Zip', over here we'd format that as 'Apartment 2, 26 My Street, A Village, A Town/City, A Postal Code'. So in certain countries, premise should come before thoroughfare on the form, and dependent_locality should also be present under thoroughfare.

xNAL is designed to have elements for all parts of an address that you might use wherever you are in the world to help with rationalising data, but it can't possibly also cover differing orders of those elements people are used to presenting their addresses in!

People over here will input it in the above order regardless of how the fields are labelled, because that's how they're used to entering their address on a form. Which means bad data displayed badly.

lightsurge’s picture

Status: Closed (won't fix) » Active

I updated the issue summary with a better description, as I think I may have been misunderstood here.

rszrama’s picture

Title: Premise not relevant as street address 2 in GB » Support an alternate street address field ordering for UK addresses
Status: Active » Postponed

Sure, reordering fields is fine and dandy. It just sounded like you wanted to subdivide a column in a way that we wouldn't be able to support due to our field schema. fwiw, there are a lot of users in the UK, and no one has reported the ordering to be an issue. Maybe they're all just dealing with bad data, who knows? But it's going to be hard to establish a consensus one way or the other.

I'm going to try for a better issue title here, but really we might just need to close this out in favor of j0rd's meta solution in #1829900: [meta] Address Field 2.x needs pluggable administrative areas and an actual API, which was intended to tackle issues like yours. Maybe I'll just mark this postponed pending on that one.

lightsurge’s picture

fwiw, there are a lot of users in the UK, and no one has reported the ordering to be an issue. Maybe they're all just dealing with bad data, who knows?

I suppose it's where an address is displayed or passed to a third party you'd expect to see problems, say for payment. However, I suspect that an address from addressfield is passed to something like paypal as a billing address just in a set order (as inputted), so in actual fact, even though the data contained may be semantically wrong, because the user has entered their address in the correct order for their country, it's probably getting passed correctly for the purposes of payment/delivery address... and indeed if it was semantically correct in addressfield, currently it may get passed for payment and other such purposes incorrectly.

If that's the case, don't know what a good solution is, maybe it's best to just stick with users essentially overriding the semantics ;-) If we want data to be semantically correct and still function properly, I guess it's not sufficient for the input form to just be re-ordered, but for the rendered address to be displayed/passed-on in the right order from the perspective of the address's country. It would be nice if we could keep a set order and just omit, insert or re-label certain elements to be country-specific, but I don't think that's the case.

There's a great guide here which shows a sample addresses in a table (also covers many other countries).

Mr. A. Smith
Acme Plc (if applicable, currently would end up in thoroughfare)
Acme House (if applicable, might be building name or flat number probably should be stuck in premise? currently would end up in thoroughfare)
3 High Street (thoroughfare? currently would probably end up in premise if above exists, otherwise thoroughfare)
Hedle end (locality or dependent locality? this would usually be a village, would currently end up in premise)
SOUTHAMPTON (post town or locality? currently would go in locality)
Hampshire (not required if post town / postal code included)
SO32 4NG

If the plan for that issue is how Damien described it http://drupal.org/node/1829900#comment-6680860 yup that sounds like it may fix this, although the title/summary of that issue doesn't make it sound like its tackling this issue, since as far as administrative area goes, in the UK it's become largely dispensable as an address component.

lightsurge’s picture

Issue summary: View changes

better explanation

ekes’s picture

Issue summary: View changes

I think the example in the Schema seems to adequately describe the normally expected order of the address for the UK; in place of house name you also have similar things for Flat 123 at a street address:-

<!--
 Mr. John W. Smith
       Russell House
       4395 Station Road
       Porchester
       FAREHAM
       PO16 8BQ
       UNITED KINGDOM
  
-->

I find it interesting that Thoroughfare itself can be split up by the way.

<Record>
 <xNL xmlns="urn:oasis:names:tc:ciq:xsdschema:xNL:2.0">
  <NameDetails PartyType="Person">
   <PersonName>
    <Title>Mr</Title>
    <FirstName NameType="GivenName">John</FirstName>
    <MiddleName Type="Initial">W</MiddleName>
    <LastName NameType="SurName">Smith</LastName>
   </PersonName>
  </NameDetails>
 </xNL>
 <xAL xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
  <AddressDetails>
   <Country>
    <CountryNameCode Scheme="ISO 3166-1">DE</CountryNameCode>
    <CountryName>UNITED KINGDOM</CountryName>
    <Locality Type="Proximate Town">
     <LocalityName>FAREHAM</LocalityName>
     <DependentLocality Type="Town">
      <DependentLocalityName>Porchester</DependentLocalityName>
      <Thoroughfare>
       <ThoroughfareNumber>11</ThoroughfareNumber>
       <ThoroughfareName>Zypressenweg</ThoroughfareName>
       <Premise Type="Building">
        <PremiseName>Russell House</PremiseName>
       </Premise>
      </Thoroughfare>
     </DependentLocality>
     <PostalCode>
      <PostalCodeNumber>PO16 8BQ</PostalCodeNumber>
     </PostalCode>
    </Locality>
   </Country>
  </AddressDetails>
 </xAL>
</Record>

So if that's not obvious sorry.
Premise does make sense for the UK.
It is required to be available for some addresses (flats and the like).
But it is a field that is only relevant to those and a few other addresses.
It is always placed before the thoroughfare line in human presentation.

ekes’s picture

And to say it in code

ekes’s picture

Oh! And to make it worse. I noticed while looking up the correct wording to use that the UK addressfield has: Town/City (locality) and County (administrative area). This is out of date, the County is no longer required - well, for the Post Office at least. However they do sometimes need the subdivision on the town:- British English 'Post town' (or Locality - xNAL) is always required, and occasionally the, in British English, 'Locality' (the neighbourhood or district within a Post Town) (DependentLocality in xNAL) is also 'required'.

kaido.toomingas’s picture

As I see you could create new formatter as I did for Estonia https://www.drupal.org/project/addressfield_estonia

bojanz’s picture

Status: Postponed » Fixed

The county is no longer required by addressfield.
The used and required fields are now a part of the address format and can be altered by hook_addressfield_address_formats_alter();

The ordering of fields on the form is not controlled by the format currently, it will probably need to wait for 2.x
I don't see any other actionable points in this issue.

Status: Fixed » Closed (fixed)

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

adamps’s picture

Status: Closed (fixed) » Postponed

I also found that this order is wrong for UK.

FYI the geocoder module in geocoder_widget_parse_addressfield creates a string from an address field like this (for all countries):
premise,
thoroughfare,
locality,
administrative_area,
sub_administrative_area, [seems like it should be before administrative_area but that probably doesn't matter as the addressfield project page says that this field is unused]
country,
postal_code,

The code is independent of country and so potentially decreases geocoding accuracy for almost all countries - the order displayed to the user and the order used in geocoding are different. UK users might end up with geocoding being done on a string containing the village followed the street.

This issue says

Support an alternate ordering

@bojanz says

The ordering of fields on the form is not controlled by the format currently, it will probably need to wait for 2.x

So closed (fixed) does not seem correct, and previous value of postponed seems more accurate. Or if you are going to close it, it seems like it should be closed (won't fix).

rszrama’s picture

Status: Postponed » Closed (won't fix)

Fixed works for me, as the library for 2.x is already completed and supports the most current UK format. But we can't won't fix it as well since this is related to 1.x.

adamps’s picture

@rszrama Thanks for the update, and sorry if I am meddling unhelpfully with your issue settings. So it sounds like the accurate status is "fixed in version 2.x-dev", but the version field for that release has not yet been created. Maybe the working v2 release is in a private development environment.

rszrama’s picture

The library is managed separately at https://github.com/commerceguys/addressing, and the next version of the module will be at https://www.drupal.org/project/address.

adamps’s picture

@rszrama Thanks for the extra info. I think other users of the module might be interested in these links too - maybe you could consider adding them to the project page? It looks like address is D8 only. Possibly address_field will not exist in D8? In which case hopefully there would be an automatic migration.

For anyone else who would like a D7 fix via hooks, here is what I used:

function HOOK_field_widget_addressfield_standard_form_alter(&$element, &$form_state, $context) {
  $element['street_block']['thoroughfare']['#title'] = 'Street';
  $element['street_block']['premise']['#access'] = FALSE;
}

You could reorder the fields in your hook, but then don't forget you would need to reorder them in the formatter too. If you already have some nodes with data for the premise field, then you need to remove that before adding the hook.