Closed (fixed)
Project:
Address Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Jun 2012 at 18:41 UTC
Updated:
16 May 2013 at 14:20 UTC
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
Comment #0.0
doublejosh commentedsubmitted
Comment #1
doublejosh commentedTried 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.Comment #2
rszrama commentedThat'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.
Comment #3.0
(not verified) commentedtypos