While importing location using the migrate module, I ran into the problem that location module would not save locations with only country set, and only when set to 'us'. The problem was that if you don't set a default in the in the collection settings, then the variable_get() is set to 'us' by default in the code. It just needs to be changed to a empty sting, and then it works properly. This should also affect anyone trying to save a location in the GUI as well if only country is set and it is set to 'us'.

Comments

frankcarey’s picture

here is the 1 line patch

frankcarey’s picture

Status: Active » Needs review
roball’s picture

Version: 6.x-3.0 » 6.x-3.x-dev
Priority: Critical » Normal
Status: Needs review » Needs work

I have applied that patch to the latest 6.x-3.x-dev version, but it didn't solve my problem with the Location CCK module: even if I have set "Please select" as the default country in the Collection settings, "United States" will be the default country when adding new content.

roball’s picture

Could you reproduce the bug I have reported?

frankcarey’s picture

@roball, I'm using 6.x-3.1-rc1 and CCK is giving me the "Please select" on new location fields. However, it doesn't look like it's actually saving the country if it is US, on if it is non-us. for some reason, is this your issue?

frankcarey’s picture

note: you have to save the default in the field settings for your cck location field (not the general settings)

frankcarey’s picture

Status: Needs work » Needs review
yesct’s picture

I'm a little confused, frankcarey, from your point of view, is this one line patch still needed and works to solve your problem? Does it cause any problems for others you think?

yesct’s picture

marked #704320: Autodetect country based on lat/lon as a duplicate of this issue
Someone please confirm that it is in fact a duplicate.

roball’s picture

@frankcarey: a patch must be against the latest CVS version and not against a version that is more than one year old (6.x-3.1-rc1)!

hutch’s picture

On #9
No this is not a duplicate, #704320: Autodetect country based on lat/lon is impossible to achieve.

This issue is about a default setting (country = us) which caused a problem with an import using the migrate module. It seems reasonable to me that the default should be country = '' but it will mean that a default will have to be willfully selected on location install. Those who do not do that should expect to find themselves in Afghanistan, hehe

I haven't tested this against a fresh install, but here is an updated patch on current CVS (hope it sticks)

roball’s picture

Status: Needs review » Needs work

The patch applies fine, however it does not solve the problem for me. In the global settings (admin/settings/location) I have the "Default country selection" changed from "United States" to be empty (the first option). On a Location CCK field, I've set the Country to be required and set its default to "Please select". I have cleared all caches.

However, when I want to create a new content of that type, the damn "United States" default is still there. This doesn't make sense to me since most of my users would select an European country. The same result without or with the patch :-(

hutch’s picture

Hmmmm.
Have you got your preferred country set in the variable table?
Look for 'location_default_country'

On closer inspection the default 'us' is sprinkled about all over the place, I suspect it would take quite a bit of recoding to get the location module and submodules to accept an empty default, not part of the original design.

On a Linux box I ran I ran
grep -rn "'us'" * | grep -v 'zipcodes' and see it in all sorts of files

It looks like you *have* to have a preferred country, mine is set to uk and that is what the country dropdown is always on.

So this patch in my opinion is not worth bothering with.

hutch’s picture

I have just done a fresh install of Drupal 6.16, using modules
Content 6.x-2.6
Location 6.x-3.x-dev
GMap 6.x-1.x-dev
GMap Location 6.x-1.x-dev
Views 6.x-2.10

I deliberately left 'Default country selection' empty and then created a new content type using location cck, also left the country field to 'Please select'. When I go to create content for that content type the country dropdown shows 'Please select'. So leaving the field empty *does* work.

Perhaps you need to go into the variable table and delete the entry for 'location_default_country' and then immediately go to admin/settings/location and hit Save configuration. Then go and edit your content types, setting the country field to 'Please select'. That might do it.

roball’s picture

Hm, didn't work for me, unfortunately. And, both defaults (globally and per-field) have originally been pre-set to "United States". I had to explicitly select it away from that, but the US default is still there.

yesct’s picture

Status: Needs work » Needs review

roball, please try it on a clean install. as a sanity check.

then the issue here is to figure out what to do to get it work on your current site, yes?
I agree with Hutch and suspect there is some setting in the db that needs to be deleted so the new changes from the dev version of the module will work as they do in a clean install.

yesct’s picture

what is a summary of this issue? Does the patch in #11 fix the importing with migrate module issue (the original issue here)?

does it cause any problems in other areas?

Maybe another issue needs to be opened for the general default country problem? (it was mentioned that 'us' is sprinkled in the code in various places).

I think a new summary of this issue will help the maintainers decide whether to commit this or not.

hutch’s picture

My own take on my patch #11 is that it does not solve anything. On a clean install I am able to switch country on and off at will (without patch) and it is reflected elsewhere, as I stated in #14
I may however not have looked *everywhere*, I was to be honest trying to get my getdirections module to work cleanly with a default of 'no country' (it does now).
So the issue in seems to me is wether a willfully selected default of 'no country' is reflected throughout, there are so many combinations of location, location_cck, gmap etc that I get a bit lost ;-(
Can anyone else reproduce the problems roball was having in #12 ?

yesct’s picture

tagging. there might be a few issues dealing with default countries, hopefully organizing will make it easier to work on them.

Stephen Scholtz’s picture

Yea, I'm having some weirdness with default countries. But then again, default countries (or default anything) and the Location CCK field are kind of confusing, 'cuz it looks to me that there are 3 different places you can set a "default country":

1. The Location settings (/admin/settings/location/main): This sets a variable, 'location_default_country', inside the 'variable' table.

2. The "Collection Settings" (inside the 'Locative information' fieldset) for an individual location cck field: This sets some defaults inside the 'content_node_field' table.

3. The "Default Value" settings, which are present for any CCK field (it's collapsed by, uh, default): I believe this sets a value inside the 'content_node_field_instance' table, in the 'widget_settings' column, although it's hard to tell exactly what's going on there. (I don't know enough about CCK or Location's internal workings, but it looks like a nested recurisive array of values, and in my experiment it seemed to include default country values from #1 and #2 above, plus #3, with 3 being the highest.)

Whatever you set #3 to, that's the one that "sticks", superseding all other values, and will show up in your content type after clearing your cache.

So roball, set the "default value" of your location CCK field to "Please select", and that's what will show up in your content.

This kind of makes sense - you're setting the default value for the CCK field, and like any other CCK field, whatever you set in there is what shows up when you create a new node. What's confusing is all the other places you can set defaults for the location field in the UI. :P

Hope that helps? So maybe this "default country" issue isn't a bug?

roball’s picture

Category: bug » support
Status: Needs review » Fixed

Yeah Stephen - this did it! I oversaw that (collapsed) "Default value" fieldset provided by CCK core. Even if I had set "Please select" on places #1 and #2, at #3 there still was the "United States" value. So just setting the desired default at #3 indeed solved the problem :-)

Thank you for this thread's most useful comment! Since the problem could be solved I think this ticket can be closed. However, Location CCK should not provide #2 at all - just adds confusions and let the user think #3 is not needed. We should probably open a new ticket for this one.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

lolmaus’s picture

#20 helped me out, thx!

shiraz dindar’s picture

word up -- #20 saved my ass. thanks stephen and others for your persistence!

weseze’s picture

This is very confusing. How can we make this less confusing?