I have 4 node forms on a single page, each with addressfield fields.

country selects IDs look like this

#edit-field-address-und-0-country
#edit-field-address-und-0-country--2
#edit-field-address-und-0-country--3
#edit-field-address-und-0-country--4

Each of the country select changes works exactly 1 time, except for the first one which will continue to work always.

This is because upon the ajax request, the ID of each other country field gets reset to #edit-field-address-und-0-country, and then it stops working.

Does this happen for anyone else?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

carsonblack’s picture

Yes, I get the same behavior with just two on the same page. The first one does not work. When there is only one on the page it works fine. The second one of two works fine as well.

j0rd’s picture

I really need a fix for this myself. I have no idea how to make it work. Any assistance would be appreciated.

ouissla’s picture

Issue summary: View changes

Hi, This is still happening on version 7.x-1.0-beta5. Has somebody found a way to around this issue.
Or can someone give me a hint regarding where the error is happening? I'm not too sure where to start.

crasx’s picture

I also have this issue. When creating multiple address fields for "billing" and "shipping" within a custom form, the ajax completely replaces all entered values

capellic’s picture

I have the same issue as described in comment #1 by @carsonblack. Any solutions yet?

My sleuthing confirms that any address field on the page, when the country is changed, an AJAX call goes out to addressfield_standard_widget_refresh, so it's not a matter of the event not firing. And I see in this code that there is a foreach that iterates over the parents to find first non-empty addressfield element. I suspect this is where the issue is but can't quite put my finger on it.

bojanz’s picture

You didn't mention how you're displaying multiple node forms on the same page.
Inline Entity Form? Panels? Something else?

bojanz’s picture

Status: Active » Postponed (maintainer needs more info)

Also, please retest using rc1 or the latest -dev.

Adirael’s picture

It happens to me too. I got a node creation form displayed with formblock and Panels plus a user edit form displayed with Panels too. I just updated to the 7.x-1.0-rc1 and it still doesn't work.

When I change the country on the user_edit_form it triggers the AJAX call but updates the node form, which is included first. I'll try to work out the reason and exact steps to reproduce ASAP.

bojanz’s picture

Status: Postponed (maintainer needs more info) » Active
capellic’s picture

My case uses the Editable Fields module (https://www.drupal.org/project/editableviews) Commerce Line Item Cart Form module (https://www.drupal.org/project/commerce_line_item_cart_form) to edit Commerce Line Item values. I have an address field attached to the line item. It doesn't work in beta5, rc1 and 1.0.

* Updated on 3/18 to correct mistake with named module.

Aron Novak’s picture

I had a little bit different issue, but I reworked the way how we detect the element when changing country using AJAX, it might provide an idea.
My issue was at a complicated Drupal Commerce instance, that country AJAX did not bring up first name + last name for order edition page, but however it did at the customer checkout form.

Aron Novak’s picture

Status: Active » Needs work