PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

For those wanting to bulk add UK Counties - here is the code

  1. I'm having to add a section to my site where the user chooses a UK mainland country, then the counties for that Country show up.

    I thought I may as well put the code here for you all to have, saving you from also having to do it.

    I've also included the form that I tested this on, so you can just add that if you prefer. please note that the form also includes 1 set of towns (when England>>Somerset has been selected).

    Here is the form for you to import:
    http://www.film-agency.com/downloads/location_example.xml

    Here is the code, which needs to be added to your functions.php file:

    add_filter("gform_predefined_choices", "add_predefined_choice");
    function add_predefined_choice($choices){
       $choices["British Mainland Countries"] = array("England", "Scotland", "Wales");
       $choices["English Counties"] = array("Bedfordshire", "Berkshire", "Buckinghamshire", "Cambridgeshire", "Cheshire", "Cornwall", "Cumberland", "Derbyshire", "Devon", "Dorset", "Durham", "Essex", "Gloucestershire", "Hampshire", "Herefordshire", "Hertfordshire", "Huntingdonshire", "Kent", "Lancashire", "Leicestershire", "Lincolnshire", "Middlesex", "Norfolk", "Northamptonshire", "Northumberland", "Nottinghamshire", "Oxfordshire", "Rutland", "Shropshire", "Somerset", "Staffordshire", "Suffolk", "Surrey", "Sussex", "Warwickshire", "Westmorland", "Wiltshire", "Worcestershire", "Yorkshire");
       $choices["Scottish Counties"] = array("Aberdeenshire", "Angus", "Argyllshire", "Ayrshire", "Banffshire", "Berwickshire", "Buteshire", "Cromartyshire", "Caithness", "Clackmannanshire", "Dumfriesshire", "Dunbartonshire", "East Lothian", "Fife", "Inverness-shire", "Kincardineshire", "Kinross-shire", "Kirkcudbrightshire", "Lanarkshire", "Midlothian", "Morayshire", "Nairnshire", "Orkney", "Peeblesshire", "Perthshire", "Renfrewshire", "Ross-shire", "Roxburghshire", "Selkirkshire", "Shetland", "Stirlingshire", "Sutherland", "West Lothian", "Wigtownshire");
       $choices["Welsh Counties"] = array("Anglesey", "Brecknockshire", "Caernarfonshire", "Carmarthenshire", "Cardiganshire", "Denbighshire", "Flintshire", "Glamorgan", "Merioneth", "Monmouthshire", "Montgomeryshire", "Pembrokeshire", "Radnorshire");
       return $choices;
     }

    http://pastie.org/1170031.txt

    When I've completed all the main towns for each County, I'll share the code :o)

    Posted 14 years ago on Sunday September 19, 2010 | Permalink
  2. sokratesagogo
    Member

    Many thanks Bawta - killed two birds with one stone for me as a newb - I was looking for info on how to add predefined lists - and a list of counties. Ty

    Posted 14 years ago on Monday November 1, 2010 | Permalink