Hi there

Great module - like th latest release.

However, I notice that not all parts of the address are displayed once a new page has been created eg. State /Province, address name

Why is this and how can I chwnge?

Thanks

Comments

mcjudd’s picture

Also I notice that for the UK not the State/Province does not appear to allow UK counties ie. North Yorkshire, Yorkshite Lincldshire etc etc

Why is this and how can I update?

THanks

NewZeal’s picture

Country state/provinces for the uk are controlled from the file countries/uk.inc. Having said that there are two bugs in the code:
1. Beginning at line 589 (in 1.05) of addresses.inc:

if (!empty($update)) {
    foreach ($countries as $country_code) {
      // Load country specifice code .inc file if it exists.
      // For example, if country_code for U.S. == 'us', load 'addresses.us.inc'
      include_once drupal_get_path('module', 'addresses') .'/countries/'. $country_code .'.inc';

      // If the country have a province list, load it
      $function = 'addresses_province_list_'. $country_code;
      if (function_exists($function)) {
        $provinces[$country_code] = $function();
      }
    }
  }

  // Return the states of a single country, if any
  if (!empty($country)) {
    if (isset($provinces[$country])) {
      return $provinces[$country];
    }
    else {
      return array();
    }
  }
  else {
    return $provinces;
  }
}

It probably should be

   if (isset($provinces[$country_code])) {
      return $provinces[$country_code];
    }
 

2. The select widget is not working so you have to enter the province code into the field.

Note that I am not a module maintainer, just someone trying to get it to work for myself. If I fix the widget I'll post here.

Note to the module maintainer: Because this is such a good module I persevered with the troubleshooting rather than pass it over.

mcjudd’s picture

Thats's great - thanks for the help. Will try this fxi this weekend.

However, with regard to the province code - what is the format ? Have tried 001, 0001 etc, but does not work Do ytou know the 'structure' / format of the code (so I can experiment) and which file in the addresses module contains this province code?

Thaks once agian for our help.

NewZeal’s picture

Have a look in /countries/uk.inc. The codes are two letters each.

NewZeal’s picture

StatusFileSize
new7.62 KB

Province Field fix Version 1 is attached. I'm a javascript newbie so in this version the 'throbber' graphic that shows while the content is loading is not working, nor can I get the js generated select items to replace the html ones so the select loads ALL provinces, which is not very good but it works. I'm making this available now in case there is someone out there who knows more about javascript than I do and can fix it and because I am putting this aside for a while to do other things, given that it does work. Well, let me know if it doesn't for you.

The attached zip has 3 files:
A new one: addresses_select.js
plus modified versions of addresses.module and addresses.settings.inc

These files are for addresses-6.x-1.05. They all do in the addresses folder.

Should I fix these problems I'll post the updated modules later

mcjudd’s picture

Hi there

Thanks foryour help. Will have a look at these in the next few days.

usa2k’s picture

Looking better, the new code adds a drop-down for states, or provinces.
Previously if the text that did not match a state, gave an appropriate error.
If the test matched, but was in lower case, it did not display on the final page.

MI displayed Michigan
mi displayed (and empty string)

!aname still remains blank for my tests.

BTW, this is a very promising module!

NewZeal’s picture

The code I've supplied has a major problem in that it cannot handle province codes that are not unique. For instance if a province in Cambodia is 'AB' and one in Australia is 'AB' and you have both those countries selected, then it can't distinguish between them. This code will work fine if you only have one or two countries selected and no clashing province codes.

The problem I cannot overcome is in changing the original select values that the script validates against. Drupal has fairly solid security against bogus entries. Someone with more programming skills than I have will be able to fix it so that it works correctly.

NewZeal’s picture

StatusFileSize
new11.54 KB

UPDATE:

I've created a module to create the country/province select functionality that does not require any changes to the addresses module. It uses the activeselect module to do the javascript work and only replaces the country and province field if these are turned off for a content type.

The modules are attached. There are instructions included. Any feedback on bugs would be helpful.

Note that this error overcomes (internally) the error on the comment here: http://drupal.org/node/382276#comment-1292746

This module saves the province as a unique value: [country code]-[province code]. On further deliberation I decided that this is not a good idea because it is different from the addresses module. If only I could change this attachment but I can't so look to the post here: http://drupal.org/node/382276#comment-1392888 for the version that saves the province in the same format.

The latest version of this module can be found here: http://webdev.passingphase.co.nz/?q=project/country-select

NewZeal’s picture

StatusFileSize
new11.27 KB

UPDATE (second attempt!):

I've created a module to create the country/province select functionality that does not require any changes to the addresses module. It uses the activeselect module to do the javascript work and only replaces the country and province field if these are turned off for a content type.

The modules are attached. There are instructions included. Any feedback on bugs would be helpful.

Note that this error overcomes (internally) the error on the comment here: http://drupal.org/node/382276#comment-1292746

This module saves the province in the same form as the addresses module.

Please download from the next post. This one has an invalid .info file (sigh, I wish I could reattach these files instead of creating a new post each time!)

The latest version of this module can be found here: http://webdev.passingphase.co.nz/?q=project/country-select

NewZeal’s picture

StatusFileSize
new11.29 KB

Third time lucky! The last .zip had an invalid .info file.

latest version of this module can be found here: http://webdev.passingphase.co.nz/?q=project/country-select

goodeit’s picture

subscribing

mrtoner’s picture

With all of the discussion on postal codes, it may not have been noted that the initial issue, "Not all fields...showing on page," has not been addressed.

With regard to !aname not appearing, it seems to me the problem is here:

address.inc, line 704

function theme_addresses_field_aname($afields) {
  return '<span class="fn org">'. theme('placeholder', $object['aname']) . $values['primary'] .'</span>';
}

I believe $object['aname'] should be $afields['aname']. (See also #374595: Address name not showing in node view.)

With regard to State/Province not showing up, it may be that you've entered data without entering a country. Here's how this works:

- If you did not select a country or if you expected to use your application in a single country and, as a result, did not include the country widget on your form, the field_address_country field will be blank (or NULL for nodes that existed prior to using Addresses)

- As a general rule, you're entering the province code when you create/edit the node, and...

- Addresses will use the field_address_country field to do a lookup on the province code and return the province name -- so unless a country is specified, province name will always be blank

- The default format templates for displaying address information (found at Administration > Site Configuration > Addresses > Address Formats) all use the !province_name token to display the State/Province. If this isn't changed (to !province_code), this will display the blank value.

Make sense?

crutch’s picture

With regard to !aname field

This is the fix.

http://drupal.org/node/374595

I applied last night and works.

NewZeal’s picture

Maybe I misunderstood the thread but when I download and use Addresses 6.x-1.05 the country field is a select field but the province/state field is just a textfield with no province data and no sign of any functionality for province data. My fix provides javascript delivery of province/states when a country is selected.

Am I missing something??

mrtoner’s picture

New Zeal, it looks like your fix addresses (pun not intended) reply #1, but not the initial post. Perhaps I misunderstood that request, but it seemed to me that mcjudd was asking why Address Name and Province weren't showing up on the node view (as opposed to node/add) after the node was created. Since I had experienced the same problem, that's what I was answering.

NewZeal’s picture

aha. Looks like I was on the wrong track.

Anyway, I know that the country data appears in the select box, but on node/add are you getting province data appearing in a select box too?

It appears that there are some things still not finished with this module. For instance the configuration options (which address fields you want to display) do not appear correctly in the config form on edit. They seem to save in the database correctly but are not rendered correctly in the form (configure an address field in a content type).

I am currently working on an addresses install so this is pertinent and I am refining my country_select module in the process

goodeit’s picture

I am wondering about the province field. If I have the US set as default (and only) country, but do not display country select on the form, then my provinces do not get displayed with the address. If I do display the country select box, it is a drop down box that has only the United States in it. Shouldn't the province be validated against the default country selected in the options if there is none selected on a node?

jantoine’s picture

Version: 6.x-1.05 » 6.x-1.x-dev
Status: Active » Closed (duplicate)

Both issues discussed here are duplicates.

1. Address name not displaying when addresses are viewed:
see #374595: Address name not showing in node view

2. Provinces as a select list dependent on selected country:
see #244471: State Field Option List

Cheers,

Antoine