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

rconstantine - November 17, 2007 - 09:25

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

mikesmullin - November 20, 2007 - 04:57

Ya, traditionally you'd do something like #location-1, #location-2, etc.

#3

rconstantine - December 3, 2007 - 22:05
Status:active» postponed (maintainer needs more info)

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).

AttachmentSize
addresses.png 22.61 KB

#4

mikesmullin - December 7, 2007 - 03:49

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

rconstantine - December 7, 2007 - 04:19

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

mikesmullin - December 7, 2007 - 04:42

It was the latter. If I get some more time, I'll try to reproduce and provide you with a better error report.

#7

rconstantine - December 17, 2007 - 21:33
Status:postponed (maintainer needs more info)» closed

#8

jennycita - January 24, 2008 - 04:24
Version:5.x-1.1» 5.x-2.1
Status:closed» needs review

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...

AttachmentSize
address.patch 1.21 KB

#9

rconstantine - January 24, 2008 - 18:49
Status:needs review» reviewed & tested by the community

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

jennycita - January 25, 2008 - 00:24

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)
a reference to the jQuery object on which this function is being called, so it's the same as $('.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()
will return an array of all the parent elements of foo, ordered from the innermost parent first, moving outwards to more distant relatives.
foo.parents('fieldset')
given said array of parents, discard all parents that are not of type 'fieldset'.
foo.parents('fieldset:first')
given the array of parents which are also fieldsets, give me only the first array entry, which will be the fieldset closest to foo. This will be the fieldset with the CCK field label as legend if foo is a CCK Address Fields form element.
var address = $(this).parents('fieldset:first')
...so to put it all together, I'm getting the innermost enclosing fieldset around the country select which just received a change event and then only operating on other form elements within that fieldset, so as to leave any other CCK Address Fields on the page alone.

#11

rconstantine - January 25, 2008 - 07:23

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

New Zeal - July 23, 2009 - 03:26
Status:reviewed & tested by the community» closed

Issue more than 6 months old

 
 

Drupal is a registered trademark of Dries Buytaert.