The 1.0 version of the module didn't actually work. I had to change it to unset() the empty items in the array. Patch is attached.

Comments

plazik’s picture

Status: Needs review » Needs work

It doesn't work for addressfield-7.x-1.0-beta5.

omerida’s picture

You mean patch doesn't apply?

plazik’s picture

No, it doesn't solve the problem.

thirdender’s picture

I had the same issue. Users had already created some address entries with just countries. This module removed the countries from the database, but the field values remained (albeit empty). The patch fixed my issue as well.

thirdender’s picture

The patch causes an issue when the address field is on any entity other than a node. I was using an address field on a Profile2 entity, and this was causing the following two errors:

Warning: Attempt to modify property of non-object in address_empty_field_process() (line 42 of /home/USER/public_html/sites/all/modules/address_empty/address_empty.module).
Warning: Invalid argument supplied for foreach() in addressfield_field_presave() (line 420 of /home/USER/public_html/sites/all/modules/addressfield/addressfield.module).

I was able to fix the error by replacing $form_state['node'] with $entity. Updated patch attached.

  • Robert Castelo committed ca2646d on 7.x-1.x
    Issue #2226527 by omerida, thirdender: Didn't actually remove empty...
robert castelo’s picture

Status: Needs work » Fixed

Thanks!

Committed to 7.x-1.1.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.