State Field Option List

nosro - April 9, 2008 - 13:47
Project:Addresses
Version:6.x-1.05
Component:Code
Category:feature request
Priority:minor
Assigned:New Zeal
Status:needs review
Description

I know you are working on the Auto-complete for the state field. Would it be possible to make an option list in the meantime, or is that just as difficult?

#1

brmassa - April 9, 2008 - 13:56
Assigned to:Anonymous» brmassa

Orson,

hmmm this is the problem. Its about the same problem i face using autocomplete.

On Location D5 i was only opted to use autocomplete because i failed in doing the same with select list. However, im had some new ideas that might be possible to do so. (Yet unsolved for disabled JS users). I will try it in a few days.

regards,

massa

#2

deviantintegral - February 7, 2009 - 19:03
Version:6.x-1.0-alpha1» 6.x-1.x-dev

This is something I'm interested in as well. For a country with a limited number of provinces, a dropdown is easiest.

At the least, the field should note that the abbreviation is to be used. Most users will end up typing the full name, causing a needless form error.

I may look at this soon :)

#3

deviantintegral - February 7, 2009 - 20:39
Status:active» needs review

Here is a patch which takes a slightly different approach. Dealing with looking up the country and showing appropriate provinces with JavaScript is a pain, and obviously doesn't work unless you combine lists for non-JS users. Instead, this patch lets users type in the full province or state name, and then converts it to the province code on validation. This also increases the maxlength for province fields to 64 characters, as 16 isn't enough for full names.

AttachmentSize
244471_allow_full_province.patch 3.75 KB

#4

codemann - March 27, 2009 - 10:17

This could be a very stupid remark, but why do you choose for an autocomplete field while a pulldown list seems so much easier for the enduser? Most big applications online where I have to register (thinking about FaceBook, Hotmail, ...) all use a pulldown list.

Are there countries with that much provinces that it would be a problem?

#5

deviantintegral - March 27, 2009 - 13:46

It's not actually an autocomplete field. Instead, it just lets you type in the full name of the province instead of just the abbreviation. So, with the patch you can now type "Ontario" instead of being forced to do "ON".

The reason it doesn't do a dropdown is because you can select multiple countries, meaning you have to do a javascript AHAH replace for the list of valid provinces if you have a large number of countries. I'm personally not against such a feature, but it would take more time to do :).

#6

codemann - April 9, 2009 - 12:30

The weird thing is I can't get it working for Belgium. When I type "Limburg" (a province in Belgium) it doesn't work. I also tried LI (abbreviation).

#7

goatvirus - April 13, 2009 - 01:14

this may sound crazy, but... i can't get this to work for ANY countries! i am running Addresses 6.x-1.05 on Drupal 6.9, using it for User Profiles at this point only... the fields appear in the User Reg page as expected, but the state/province field is showing up just as a regular textbox, with no autocomplete or select list or anything else to tie it to those lists of states/provinces in the addresses/countries/*.inc files... what do you need to turn on to use this feature?

cheers
Fish

#8

deviantintegral - April 13, 2009 - 01:37

@codemann: So it works for other countries? Try Canada and see if it works (since that's what I tested with).

@goatvirus: Please see my comments in #5. This patch doesn't implement full auto-complete functionality, but simply allows users to use the long or short forms of provinces. A patch implementing #autocomplete functionality would be nice though, so feel free to write one up!

#9

codemann - April 14, 2009 - 08:55

@deviantintegral: it works when I use "VLI", which is the code that I found in be.inc. But the full name is "Limburg" and in short I would try "LI", but off course not "VLI", the V has no meaning there. I assume that "VLI" is used because "LI" was already used elsewhere?
An autocomplete or even better a pulldown of the full names would be the feature everyone wants off course! :)

#10

rsm08 - April 26, 2009 - 13:23

I think the whole concept of allowing users to freely type in province names and having to match an entry in a limited list of provinces it just plain crazy from a usability perspective.

First of all, people are going to make spelling mistakes, as most people are bad spellers. Secondly, there could be numerous spelling variations or aliases for one province, which in practice reduces the province field to a guessing game.

Also, there'll always be provinces that aren't in the database.

Personally I haven't yet been able to type in anything that this field would accept. Luckily we don't have provinces in my country, so if our users just leave the field blank, we won't have problems there, but whenever someone from abroad tries to register, they're told that the province they typed in doesn't exist.

Of course everyone who tries to enter an address with a province on my site gets furiously mad. And I can totally understand them.

So if users can only choose from a pre-defined list of values, a select box should clearly be used. But why not - even better - remove the pre-defined list and make users type in what they want?!

#11

AmitV - May 6, 2009 - 11:03

Subscribing....Need an option list

#12

shah.arpita85 - May 11, 2009 - 19:05

Is it possible to get a drop down list for state and city?

#13

scs_calleros - May 24, 2009 - 03:40

Subscribing...

#14

GrimSage - May 24, 2009 - 10:47

What about using something like hierarchical select http://drupal.org/project/hierarchical_select
It would seem to be perfect for something like this.

#15

harpowned - June 15, 2009 - 16:49
Category:feature request» support request

suscribing too, I've been unable to input anything the field will accept, this will drive all our users mad, so this module can't be used until this is fixed. Good work with the rest of it, though!

#16

Dasha_V - June 19, 2009 - 09:09

This is what I’m using to have a states(provinces) as select list that is auto-populated each time the county is changes (USA is default):

  1. http://drupal.org/node/182310 - add #DANGEROUS_SKIP_CHECK as it was in Drupal 5

    In /includes/form.inc need to replace

    if (isset($elements['#options']) && isset($elements['#value'])) {
    with
    if (isset($elements['#options']) && isset($elements['#value']) && !isset($elements['#DANGEROUS_SKIP_CHECK'])) {

  2. I’m attaching 2 files that you need to replace in addresses module(6.x-1.05) :
    addresses.module
    addresses.settings.inc
    just take a look on functionality that’s has //New: mark in comments
  3. The changes in this files to make states auto-populate working are:
    1. Add new menu item
      i. Path admin/settings/address/province/%/%
      ii. Callback _addresses_get_states($field_name, $delta) in addresses.settings.inc
    2. Add new functions arguments to use form element values as #name, #id
      i. addresses_addressesfieldapi($op, $fields = array(), $values = array(), $element = array())
      ii. _addresses_addressesfieldapi_form($fields = array(), $values = array(), $element = array())
      iii. everywhere where this functions are used
    3. Add #ahah behavior for country and select for provinces (states)
      i. $form['country']['#ahah'] = …
      ii. $form['province']['#DANGEROUS_SKIP_CHECK']
      iii. Default country is USA
AttachmentSize
addresses.zip 7.21 KB

#17

DickSwart - June 26, 2009 - 12:58

suscribing - need dropdown for province/state.

#16 works with warnings and don't want to modify core files.

#18

GrimSage - July 14, 2009 - 12:42

this module http://drupal.org/project/profile_location seems to have found a way to implement this. Not sure exactly if it will be what is needed, but it might help.

#19

zmove - July 23, 2009 - 13:17

Don't have time to submit patch, but this should be quite easy using core #ahah drupal possibilities with 6.x.

#20

Dasha_V - September 7, 2009 - 17:03

fix #16 to work with user_addresses (#16 was for CCK only)

AttachmentSize
addresses.zip 7.21 KB

#21

New Zeal - September 27, 2009 - 08:35
Version:6.x-1.x-dev» 6.x-1.05
Component:User interface» Code
Category:support request» feature request
Assigned to:brmassa» New Zeal

#22

New Zeal - September 27, 2009 - 08:38

Attached is a module for the addresses module that creates a select dropdown of provinces for the selected state and saves it correctly. This module works in most standard installs. For it to work two conditions apply:
1. country and province fields must be switched off in addresses configuration for the content type
2. the country_select module has to have a higher weight than the content module. The .install file sets it to 1 so it should work out of the box if weights have not been changed.

Package also includes the activeselect module which is required.

Enjoy
Passing Phase Web Development

AttachmentSize
country_select.zip 11.85 KB

#23

chris.peplin - November 5, 2009 - 22:47

subscribing

#24

tomotomo - November 19, 2009 - 20:13

Out-of-the-box the provinces in this module are unusable for UK users. Making users have to guess the format of this field is unreasonable. Until that's fixed I have to abandon this module.

 
 

Drupal is a registered trademark of Dries Buytaert.