two cck_address fields = 2nd doesn't work
mikesmullin - November 17, 2007 - 00:57
| Project: | Address field for CCK |
| Version: | 5.x-2.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
try creating a content type with two cck_address fields. the second field will not populate the state and country dropdowns. i'm guessing this is a .js error but don't have time to look. just thought i'd let someone know...

#1
I bet you're right. Funny how I've never needed two addresses myself before. Anyone know a good way to uniquely name an id that js can target? If not, I'll just look it up.
#2
Ya, traditionally you'd do something like #location-1, #location-2, etc.
#3
I just tested this and I'm not having any problems. See the screen shot attached. My example just has the standard module activated, no additional countries, but that shouldn't make a difference since the fields are populated from the same code and the extra modules simply add more data to the database.
So unless you can provide more info, I'm going to have to assume it's a problem on your end.
By the way, you aren't on GoDaddy.com are you? If so, see some closed issues about that (i.e. there are problems).
#4
I gave up and started making a CCK field for Location.module, instead:
http://drupal.org/node/183004#comment-634112
Sorry. I wasn't on GoDaddy though...
#5
Bummer. Well, too bad you didn't get it working. It would have probably been better to integrate your efforts with this module. There are a couple of postponed feature requests regarding integrating this with location. But that's your choice.
There is a new version, by the way. Did you try it as well?
One quick question: were you trying to use the field's multiple check box, or were you trying to put two different address fields on one content type? My example is of the latter, and I'm pretty sure I disabled the multiple check box at the field settings level.
#6
It was the latter. If I get some more time, I'll try to reproduce and provide you with a better error report.
#7
#8
I was having the same problem. On my box, it's reproducible every time if I select United States in the first address field, then the first *and* second address fields' states become drop-downs (with no country selected in the second address field). If I then select a non-US country in the second address field, the state select is emptied of values, but no text field is provided, so it's unusable.
I've attached a patch that will localize the jQuery operations to the current fieldset only. Solved my problem...
#9
Hmm. I thought I killed that. For some reason, I don't have a problem with that. Very strange. In any case, I've looked at your code and it seems reasonable. I need to brush up on my COM selection - what does the first line you added do exactly? Could you explain it? The other lines I understand just fine. Thanks for the patch!!! I love patches!!!
#10
It suddenly occurred to me that my patch might depend on the JQuery Update module. I hope not... I'm not entirely sure what new functionality is added by the latest version of jQuery... but I wrote my patch on an install that has the updated version. If you didn't get any JS errors, it should be fine.
Anyway, the first line.
$(this)$('.cck-address-country select'), except that the latter will act upon all country selects found in the current document while the former will act only on the one which just received a change event.foo.parents()foo.parents('fieldset')foo.parents('fieldset:first')var address = $(this).parents('fieldset:first')#11
Thanks. I hadn't seen the last two parts before. I've wanted to get into jquery, but I just haven't had a project that required it yet. However, there is a ton of jquery stuff that could be done to enhance all of my modules had I the time to do it.
I'll check the dependency. I don't have the stock version either, but I don't have the latest. Perhaps if anyone else reads this thread, they can comment if they try your patch.
#12
Issue more than 6 months old