We are using addressfield_autocomplete widget in a multiple Postal address field. We have set the following configurations for the field:

  • Address form (country-specific): TRUE
  • Hide the postal code: TRUE
  • Hide the street address: TRUE
  • Hide the country when only one is available: TRUE
  • Organisation (single line): FALSE
  • Name (First name, Last name):FALSE
  • Name (single line): FALSE
  • Make all fields optional (Not recommended): TRUE
  • Default country: Canada
  • Available countries: Canada
  • Show map: TRUE
  • Reveal widget: FALSE
  • Place types: (cities)
  • HTML5 geocode: TRUE
  • Draggable markers: TRUE
  • Visible markers: TRUE
  • Reverse geocode: FALSE

After creating a node with one or more address (cities), when the user tries to edit it:

  1. Edit form opens with a new empty address item (this is standard Drupal behavior for multiple fields)
  2. The user cannot delete this new address he does not need (because there is no delete option for address items on the multiple field)
  3. User clicks Save or Delete
  4. Error message "City field is required." is displayed, because the new address item was not set
  5. It is not possible to save or delete the node

This happens because, in line 399 of addressfield_autocomplete_field_widget_form method, locality field is set as required, even though "Make all fields optional" option is enabled.

Comments

deivamagalhaes’s picture

deivamagalhaes’s picture

New patch on top of 7.x-1.0-beta5

ptsimard’s picture

Status: Active » Needs review

Using your patch because I ran into a similar issue while using geofield module along with this one.

Seems to work (patch #2 was not applying on beta-5 btw due to wrong path in the patch and an extra space) but patch #1 applies correctly on latest dev.

The last submitted patch, 1: city-field-should-not-be-required-2487049-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 2: city-field-should-not-be-required-2487049-2.patch, failed testing.

The last submitted patch, 1: city-field-should-not-be-required-2487049-1.patch, failed testing.

ptsimard’s picture

Version: 7.x-1.0-beta5 » 7.x-1.x-dev
Status: Needs work » Needs review

adammitchell’s picture

Status: Needs review » Closed (fixed)

Hi deivamagalhaes,

Sorry for the delay, I have reviewed and committed your patch to the dev branch.

Thank you for your help.

Adam