Not sure why by AddressField seems to call all form validation functions that have been added via form alter while it's building the form via AJAX. The form isn't submitted yet.

This is causing some serious headaches while trying to make use of FAPI Validation. To use that module, you just add additional properties to form element arrays, but those seem to add elements which aren't present during the addressfield AJAX load... but it calles validation functions which do expect those element to be present. Seems like a mess.

Perhaps it's my naivety of the Form API validate/submit/build process, but why would AddressField call form-wide validation functions while building elements via AJAX?

Comments

doublejosh’s picture

Issue summary: View changes

submitted

doublejosh’s picture

Tried surrounding my code which adds the validation function with if (!$form_state['submitted']) { thinking that the AddressField was prematurely submitting, but that doesn't seem to be the case. This verifies the $form_state is acting correctly. But various validation functions should still not be called.

rszrama’s picture

Title: AJAX calling all hook validation functions » Why does the Address Field AJAX refresh call all form validate functions?
Category: bug » support
Status: Active » Fixed

That's just the way the AJAX refresh works within Drupal. When an AJAX event is triggered, it sends all the form data to Drupal, which uses it to rebuild and validate the form input before returning some updated part of the form back to the browser to be replaced onto the page. Address Field uses #limit_validation_errors to ensure that any errors generated as a result of this validation are suppressed, but note that the property is no called #skip_validation - I used to assume it wasn't calling the validate handlers, but it does and just ignores the results.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

typos