Country dropdown doesn't show
weedoo - June 13, 2007 - 14:55
| Project: | Address field for CCK |
| Version: | 5.x-1.x-dev |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | rconstantine |
| Status: | closed |
Jump to:
Description
I just installed this module for CCK + I added canadian module as well. There might me something I'm doing wrong because even after enabling the canadian module, I can't see the country dropdown when I try to add a node that has address field. The only thing I get when trying to post a fully filed node is this error, "Illegal value for Address's Country field. You must select a Country from the dropdown list.".
Anyone know what I'm doing wrong ?

#1
I am also running into this problem and have been unable to resolve it myself.
#2
Same here. First I had only USA enabled, no dropdown showed. I tried every combination of options. Then I enabled Canada too (figured, maybe it needs two countries at least to show the dropdown), still no go. I'm going to dig in the code a bit, after I do a local install, and try to figure it out.
#3
I got it !, if you want to fix this problem, install Active Select module which enabled ajax for the dropdown menu. Worked for me ! hope this is useful for you 2 !
#4
Hmm. If you are all using the latest dev version, perhaps I mistakenly screwed something up. I made a few changes to get the 'other' country option to work. Although the ActiveSelect module is required for 'dynamic' AJAX goodness for filling the state/province field, without it, there should still be a country drop down as well as a state drop down. The only difference is supposed to be that the state drop down, if multiple countries are enabled, will be restricted to the currently selected country rather than one giant list of all states from all countries. For, now, yes you can use ActiveSelect and it will work. However, I will take a look at what I changed.
Thanks for the heads-up.
#5
I have enabled Active Select and it still gives me an "illegal choice" error... It highlights "Select table to use for addresses:" even though the checkbox above it is not checked. Any thoughts on this?
#6
That's in the admin, right? Um, that may be another thing I overlooked.
I did just fix the other problem. It seems that when I tried to get clever with my 'if' statements, and then later changed my mind, I didn't out the simple '#type' => 'select' back into the country drop down definition.
Let me look at this admin problem real quick, then I'll upload to CVS.
#7
One other thing you might be interested to know, once your module has been installed, I keep getting blank page wieh adding or editing node, data is saved, but I need to reload the page to see something... I get this message all the time, and more than once
warning: Invalid argument supplied for foreach() in /Users/Olivier/Sites/drupal-5.1_slc/sites/default/modules/cck_address/cck_address.module on line 1331.
thanks for your great work and quick reply
#8
Hopefully these two things are fixed. The drop down issue will be for sure.
As for the admin thing, I have just made each of those fields in the new section depend on the first checkbox for their 'requiredness'. Let me know if that works. Since it seems that there are several of you out there today looking for a fix I wanted to get this to you ASAP and so haven't made sure this part is 100% yet.
In any case, you should be able to fill out the dropdowns in the new section with bogus info and it simply won't be used unless that first checkbox is checked. So if my fix doesn't actually fix it, then this is a work-around for now.
BTW, I'm not validating these fields myself in this module, so I assume CCK itself, or even Drupal core is throwing that error, not this module. So that means I just need to figure out how to make them happy without requiring you to fill those out. Hopefully my first guess worked. Let me know.
It's now available here: http://cvs.drupal.org/viewcvs/drupal/contributions/modules/cck_address/c...
As usual, cron will update the project's tarball sometime in the next 12 hours.
#9
For me, yes, it's in admin when I'm editing one of my content types.
And as was said, thanks for your prompt response and hard work! :)
#10
@weedoo
Since I just changed the code, the lines have changed. Either quote the line for me, or I'll try to look at a diff to figure out what line 1331 was.
Thanks.
#11
@weedoo
Nevermind. I see the function and know the cause. For now, use the work-around if the latest CVS doesn't fix that too. Meanwhile, I'll take another look.
#12
@weedoo
The problem is that the activeselect function for the new dropdowns in admin is firing and there's no selection made. I'm trying to make the activeselect function quit before it gets to the spot that gave you the error if you aren't even using that feature.
Yet another upload to CVS will be forthcoming.
#13
@ ScislaC & weedoo
I think the latest CVS handles both issues without the workaround. Let me know. In my testing, I've got this set: ActiveSelect is On, 'Select with full names' is chosen, 'United States' is chosen, and everything in 'Select from DB' is left to itself (the first table is loaded and the dependent ones get the first column name; the country loads Alabama into the state field automatically). By not doing a thing down there (which is what I assume you were doing), it seems to validate okay now.
#14
rconstantine: I just set up another Drupal install hoping a fresh start would help... I still get that same validation error with the same options you suggested. I also replaced the old ".module" with the cvs one you uploaded, but in both my old install and new one I'm now getting the following errors:
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SHOW COLUMNS FROM in /var/www/site/includes/database.mysql.inc on line 172.
* warning: Invalid argument supplied for foreach() in /var/www/site/modules/cck_address/cck_address.module on line 1331.
* warning: Invalid argument supplied for foreach() in /var/www/site/modules/cck_address/cck_address.module on line 1331.
* warning: Invalid argument supplied for foreach() in /var/www/site/modules/cck_address/cck_address.module on line 1331.
* warning: Invalid argument supplied for foreach() in /var/www/site/modules/cck_address/cck_address.module on line 1331.
* An illegal choice has been detected. Please contact the site administrator.
Any thoughts? (note that I didn't see any of those errors until I updated that module file)
Again, thanks for your time and hard work!
#15
Which version of MySQL are you using? I wonder if this is a MySQL 5+ only feature, though I don't think so. I thought SHOW COLUMNS FROM {your table name here} was a valid statement for 4x...
Am I to understand that this is happening when you try to view the admin page at all?
If you are running 4x, do you know of any equivalent SQL query?
#16
MySQL 5 here
#17
5 hmm...
Well, ...
Are you seeing the admin page at all? I think you missed that question above.
The issue revolves around the idea that tables from your db might not be found; in other words, information from before the call to the function is not be gathered correctly, so the function takes a dump when we get there. Try this for me if you would since I can't seem to duplicate your problem:
Just after this -
$all_tables = array();$sql = "SHOW tables";
$results = db_query($sql);
while ($result = db_fetch_object($results)) {
$all_tables[$result->Tables_in_drupal5b1] = $result->Tables_in_drupal5b1;
}
put this -
drupal_set_message('<pre>All tables: ' .print_r($all_tables, TRUE). '</pre>');If you go to the admin page and it craps out before you can see the messages, just hit your back button and I think it'll show up.
Let me know. If it shows this: "All tables: " and nothing after it, then we have a problem with the code just above.
#18
I'm an idiot. I didn't even look at the code I just posted. Of course you have a problem!!! I've hard coded the name of my DB!!! For now, replace "Tables_in_drupal5b1" in both instances with "Tables_in_XXX" where XXX is the name of your database.
Sorry. I'll fix that soon. Meanwhile, all you party people, do the above.
#19
Woohoo!!! That did the trick! Thanks for your time and hard work rconstantine! :)
#20
No problem. Thanks for your patience.
My normal practice when I do something like hard-coding, is to immediately write a TODO near it so I don't forget to change it before posting. Looks like I missed this one. Anyway, I'm fixing it now. Will be in CVS shortly... if that's all of the issues for this time around.
Then I'll get back to my new module - it lets you add a drop down on the registration page which will then route the user (after they submit the page) to a pageroute (see the pageroute module) of your choosing. When used in conjunction with nodeprofile, this should allow one site to have several different kinds of registration/memberships. I'm just starting it, so wish me luck.
Then later this week or this weekend, I hope to update the Content Types Administration by Organic Groups module, followed, by an update to OG_forum as well.
#21
committed to CVS.
#22
thanks so much it did the work correctly, thanks for your time and keep up the good work, I'll keep you posted with any bugs I can find !
#23
Ok, sorry for this last comment, I still get the white screen. I got the latest dev version and replaced my old old one with it. Doesn't seem to be getting the 4x 1331 error anymore, which is good ! When I edit an existing contact, I still get the white, url at this point is node/299/edit, I refresh that page, and get the modification successful + this error
warning: Cannot modify header information - headers already sent in /Users/Olivier/Sites/drupal-5.1_slc/includes/common.inc on line 311.
I understand this one, but the white page is still mystery.
Thanks !
#24
@weedoo
Do me a favor and open a new issue for the white screen. Then we'll pick up the discussion there. And while you're playing with things, let me know if you still get the white screen with the ActiveSelect module disabled. In fact, if you're only using the U.S., there is no functional difference in operation unless you need that crazy stuff I added to the admin for known addresses.
#25