In the United Kingdom, addresses do not have 'States'. Addressfield however requires you to supply one.

The offending line is in plugins/format/address.inc:


// Those countries generally use their administrative division in postal addresses.
  if (in_array($address['country'], array('AR', 'AU', 'BR', 'BS', 'BY', 'BZ', 'CA', 'CN', 'DO', 'EG', 'ES', 'FJ', 'FM', 'GB', 'HN', 'ID', 'IE', 'IN', 'IT', 'JO', 'JP', 'KI', 'KN', 'KR', 'KW', 'KY', 'KZ', 'MX', 'MY', 'MZ', 'NG', 'NI', 'NR', 'NZ', 'OM', 'PA', 'PF', 'PG', 'PH', 'PR', 'PW', 'RU', 'SM', 'SO', 'SR', 'SV', 'TH', 'TW', 'UA', 'US', 'UY', 'VE', 'VI', 'VN', 'YU', 'ZA'))) {
    $format['locality_block']['administrative_area'] = array(
      '#title' => t('State'),
      '#size' => 10,
      '#required' => TRUE,
      '#prefix' => ' ',
      '#attributes' => array('class' => array('state')),
    );
  }

The check for the UK ('GB') should be removed.

Comments

FrancescoUK’s picture

I agree, that's a non sense and I commented out /* 'GB', */ in my installation

rogerb’s picture

Agreed, no state field required for UK address.

All that is required for post to be delivered correctly is the house/building number and post code. For example:

23
SE10 9QQ*

* Not a real post code.

andyf’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.21 KB

Agreed, State means nothing in the UK. Patch attached.

isktech’s picture

Some UK agencies still require "County" name even though not required for mailings. I made a second "if" block just for UK, changed the administrative_area title to "County" and set required to FALSE.

FrancescoUK’s picture

If you ask which County are you in to a Londoner, they will most likely struggle to give you an answer!
It's indeed better to set false by default, as I don't see it used that often.

http://en.wikipedia.org/wiki/County_of_London

srlawr’s picture

StatusFileSize
new1.91 KB

Firstly, I definitely agree that "State" is inappropriate for a GB address.

Secondly, whilst I also agree that some people might struggle with a correct answer for "County" (I live in Bristol, formally of Avon, now a county in it's own right... or is it?!) I believe it is a valid part of a UK postal address.

Therefore I submit a different patch from #3, and to the tune of #4 - that makes a special case of GB to present a county box, slightly longer (for Worcestershire and the like) but that is not required, so as to lower the barrier of entry.

wipeout_dude’s picture

Patch in #6 works perfectly for me.. I vote to include it in the module please!!

mrfelton’s picture

I think we need a full UK counties list here. Yes, some people refer to these things slightly differently to others, but a great many systems provide a well thought out list that makes it easier for people to enter their address. Not only does it make it easier to enter an address, but it also ensures consistency of data. If you let people just enter any old thing into the County field, then you you end up with a whole bunch of crappy data, which is often mostly useless.

I went through a process with the CiviCRM developers and mailinglist a couple of years back to come up with a suitable list and get it included in the CiviCRM core. Some of the discussion is on http://issues.civicrm.org/jira/browse/CRM-5224 though a lot of it took place over the mailing list. I would recommend that we use the final list that exists in CiviCRM today for our purposes here too.

adam_b’s picture

I don't object to the existence of a list, as long as it's optional (and doesn't leave a "--" in the address if nothing's selected).

roblav’s picture

Ignore this wrong issue - refers to http://drupal.org/node/1345198

roblav’s picture

StatusFileSize
new5.95 KB

Here's the correct list counties for the UK, ignore previous post #10

wipeout_dude’s picture

I think handling it as a list is a great idea..

What would it take to get patch #11 rolled into the module quickly?

mrfelton’s picture

It would take positive feedback from several testers, and the module maintainers approval on the approach and implementation. So, get testing, and give us your feedback!

joachim’s picture

Status: Needs review » Needs work
StatusFileSize
new5.4 KB

A few points:

> I believe it is a valid part of a UK postal address.

Counties are no longer a required part of a postal address in the UK. See http://en.wikipedia.org/wiki/Postal_counties_of_the_United_Kingdom

What are the codes in the patch, such as:

> 'AC' => t('Aberdeen City'),

Are they just made up by CiviCRM developers?

It would be better to use something standard rather than a custom code. Unlike US states, there are no official county abbreviations, but Wikipedia does however throw up this: http://en.wikipedia.org/wiki/ISO_3166-2:GB We could use the three-letter part that follows the 'GB', thus:

> ABE Aberdeen City

At any rate, here is the latest patch rerolled for whitespace and comment formatting (and also in comments, the name of the country is UK, even though the code is GB...)

joachim’s picture

So digging into the git log a bit, I can see that there use to be a file addressfield_form_gb.inc, which had a 'County' textfield. This was added prior to alpha2.

Prior to beta1 though, all the inc files were replaced with plugins, and that's where this became 'State'.

So we should probably just fix the regression back to a 'County' textfield here.

The matter of a dropdown for counties is a complex one, and as well as the correct way to produce the list, there are matters of data storage to consider: every UK address saved already will contain freeform text which not necessarily match up to the options a new dropdown would provide.

wipeout_dude’s picture

I agree.. Just get the field label corrected so that at least the user experience is correct.. The patch in #6 achieved this for me and its super simple..

netivajak’s picture

In light of the Royal Mail's apparent desire to remove County usage in the postal network entirely (2013 culling obsolete and possibly 2016 remove all) perhaps instead hide the county/state field for UK addresses?

If it were ever necessary to reinstate (sorry) them, this could be repopulated (with whatever comparisons for previously stored data sanitisation) using the Postcode Address File (which shouldn't be a "product" imho but that's a different rant).

Apologies for excessive use of ().

Yes people get possessive about the counties - heritage, history &c but this is about getting goods or information to people's addresses after all and the less information gathered the quicker the form is to complete and therefore fewer errors?

edit -> The PostCode Address File according to Royal Mail "is the only complete source of all known UK Postcodes." Information on this is here: http://www.royalmail.com/marketing-services/address-management-unit/addr...

mrfelton’s picture

> This is about getting goods or information to people's addresses after all and the less information gathered the quicker the form is to complete and therefore fewer errors

No, it's about accuracy and consistency of data. Addresses captured through addressfield can be used for a million things over and above Royal Mail.

wipeout_dude’s picture

As mrfelton says addresses are used for many more things than just mail and the general UK population are all used to using a County.. If Royal Mail are eliminating it over the next few years it will probably take another 10 after that before its the normal way of writing an address.. Therefore I believe its necessary to have it available as a field..

joachim’s picture

> Addresses captured through addressfield can be used for a million things over and above Royal Mail.

But if an address correctly contains a postcode, then it can be mapped to anything you need. And often, that's not going to be a county (because it's a school catchment area, a parliamentary constituency, and so on). Or it's going to be an administrative area -- and if you ask people for 'county' they often won't give you that, because they still think of themselves as being in Thingshire rather than the Unitary Authority of City. So I don't think that the county is particularly useful data to ask from people: if you need it, you're better of deriving it from the postcode.

It would be nice if we could come to a consensus on this -- otherwise we'll end up in the same quagmire as we did with Ubercart UK addresses, where the thread dragged on forever and the non-UK-based maintainer understandably left it to simmer for ages.

Hence why I suggest a textfield, which is what this module had to begin with, which at least gets us something we can put in front of clients and end-users without them going 'WTF'.

mrfelton’s picture

> But if an address correctly contains a postcode, then it can be mapped to anything you need

If you are Royal MAil yes, or have access to some other postcode lookup system, but a lot of people dont have this, and what they want is to ensure that the data that they are capturing is accurate, consistant, and usable in whatever system they are working with, be it another database, application, web service, or simple spreadsheet. The assumption that postcode alone is enough is just wrong, sorry.

A text area really does not cut it to enable organisations to collect meaningful and usable data. we have a list of counties, which I bet you at least 95% of the UK audience can identify with - lets use it.

tahiticlic’s picture

Same for French Polynesia ('PF' iso code). There should not be State field.

Is there a hook to modify the format after it is generated, or to extend the format definition?

joachim’s picture

> we have a list of counties, which I bet you at least 95% of the UK audience can identify with - lets use it.

The matter of a dropdown list should be moved to a new, follow-up issue. There are several reasons:

1. This issue is a bug report about the regression in beta 1. We shouldn't drift it.

2. Changing to a dropdown requires data migration. Any site that has already been using an addressfield for UK addresses will have tons of records that are incorrect. There are bound to be typos, and furthermore there will be downright inaccuracies. For example, how many people in Edinburgh do you think will have typed in 'Edinburgh, City of'?

3. The dropdown debate will run and run. It will take forever to reach a consensus. In the meantime we have a major UI bug which affects end-users. We should get the 'state' label fixed first, and then go debate the dropdown plan: let's not allow the search for perfection to get in the way of fixing the problem.

srlawr’s picture

I just thought I'd pop back here to say, whilst the debate rages on, my client has decided that the "County" field does need to be mandatory (in this case) and so, despite my own patch in #6 being a fairly popular fix, I have now had to add my own hook_form_alter to override it :D

Sometimes you just gotta laugh.

joachim’s picture

Status: Needs work » Closed (duplicate)

Looks like this was in fact already fixed here: #1219658: GB Specific Changes and is in the dev release.

If people want to debate a list of counties, please open a new issue. Though in my opinion, such a list is doomed for the reasons I gave above.

mrfelton’s picture

I have created a follow up in #1630834: UK Counties list with a patch that applies cleanly to latest dev code, that adds the UK counties list discussed earlier in this thread.