Problem/Motivation

If an address field is not required, any 'required' address components will nevertheless be required on form validation. For example, a US address requires these components: address line 1, city, state, zip and error messages will display for any that are empty. This is quite inconsistent.

The 'Make all fields optional' format handler attempts to address this, although in a manner 'unsuitable for postal purposes' as stated by the module.

Steps to reproduce

  • add an address field to an entity,
  • set it to not be required,
  • display the edit form,
  • leave a required address component empty,
  • click save

Proposed resolution

Add a 'format' plugin for a conditional address. This plugin will only validate an optional address if at least one required component is set. In this way, if the user does not enter an address, he will not be shown error messages. However, the user will not be able to save an incomplete address.

Remaining tasks

Review and test manually, no automated tests to be written.

User interface changes

None on entity edit form; new format handler on manage field form.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

solotandem created an issue. See original summary.

solotandem’s picture

Issue summary: View changes
solotandem’s picture

Status: Active » Needs review
FileSize
3.83 KB

Attached patch implements proposed changes.