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.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 1844918-07-alternate_street_address_order_uk.patch | 922 bytes | ekes |
Comments
Comment #1
rszrama commentedI'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.
Comment #2
lightsurge commentedJust 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.
Comment #3
lightsurge commentedI updated the issue summary with a better description, as I think I may have been misunderstood here.
Comment #4
rszrama commentedSure, 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.
Comment #5
lightsurge commentedI 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.
Comment #5.0
lightsurge commentedbetter explanation
Comment #6
ekes commentedI 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:-
I find it interesting that Thoroughfare itself can be split up by the way.
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.
Comment #7
ekes commentedAnd to say it in code
Comment #8
ekes commentedOh! 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'.
Comment #9
kaido.toomingas commentedAs I see you could create new formatter as I did for Estonia https://www.drupal.org/project/addressfield_estonia
Comment #10
bojanz commentedThe 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.
Comment #12
adamps commentedI 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
@bojanz says
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).
Comment #13
rszrama commentedFixed 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.
Comment #14
adamps commented@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.
Comment #15
rszrama commentedThe 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.
Comment #16
adamps commented@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:
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.