I have a very specific situation where I run into problems with the Addressfield field that I need help with.

I have a node type that holds several fields (a.o. file/image fields) and one field collection that is set up as a multiple field. Within the field collection there is an addressfield field and some other textfields.

The issue is that when on the node edit form a user edits one or more of the file/image fields, on submit, the edit form is reloaded without any message whatsoever (not on screen, not in de log and not in the apache log).

It took me a long time (eventually by eliminating every possible cause) to figure out that it is the field_collection "multiple value" setup combined with the addressfield field that causes this behavior.

Specifically the next lines of code in the addressfield.module file creates the effect of the form reloading wihout any message:

function addressfield_standard_country_validate($element, &$form_state) {
  // If the country was changed, rebuild the form.
  if ($element['#default_value'] != $element['#value']) {
    $form_state['rebuild'] = TRUE;
  }

Somehow when a users changes a file field (which triggers the form to be rebuild) the $form_state['addressfield'] that is used in the addressfield_field_widget_form() is no longer filled with whatever was filled in before which causes comparison of the #default value and the #value to return TRUE.>

Commenting out the above code fixes the problem, so I was wondering what this piece of code is in there for?

Comments

ezeedub’s picture

Category: support » bug
StatusFileSize
new684 bytes

I got this as well. Removing this check worked for me, and I haven't noticed any adverse side effects.

ezeedub’s picture

Status: Active » Needs review

changing status

marty2081’s picture

Since we fixed this in March by removing the check we haven't seen any adverse side effects either (or any answer here for that matter).

skessler’s picture

Was this committed to the dev branch? Thanks!

rogical’s picture

Did you apply the patch? I failed to apply it, seems the dev codes was behind of the release version.

tien.xuan.vo’s picture

StatusFileSize
new606 bytes

Updated the patch from #1 against 7.x-1.0-beta4.

jsibley’s picture

Any progress on getting this committed?

Thanks.

jurgenhaas’s picture

Issue summary: View changes

Same issue here and removing that one specific test resolves the problems and no side effects have materialized (yet).

bojanz’s picture

Status: Needs review » Closed (duplicate)

Please test the patch in #2222819: Check triggering_element before setting $form_state['rebuild'], it's less problematic.

marc delay’s picture

Status: Closed (duplicate) » Active

Sorry, this seemed like a duplicate, but based on the closing reason for the other bug this is not. This one effects the proper expected results of a working system where the other one effects out-of-bounds functionality.

It does seem like the patch attached to the other issue is a much better place to start than just snipping out offending lines of code.

socialnicheguru’s picture

Status: Active » Needs review