[development] D7 AJAX API change: Submit and Validation

Randy Fay randy at randyfay.com
Fri Mar 26 23:07:46 UTC 2010

If you're working with D7 AJAX Forms, you will be interested in an API
change this week.

With http://drupal.org/node/684846, the AJAX triggering was refactored, and
this has some effects on those of you using it:

The bottom line: The submit function and form_set_error() actions only take
place when the entire form is submitted, and do not take place in an AJAX
triggered event (unless it's submitting the entire form).

1. Fields don't get errors reported against them in the context of a
single-element AJAX event. So for example, if you're triggering on a select
and there is another required field in the form, form_set_error() will not
report the fact that the other required field is still empty.

2. The _submit() function is *no longer* executed during an AJAX submission,
only when the form itself is submitted. It's only run when the whole form is
submitted. If you have behavior in your module that depends on this, you'll
have to change this.

I had some contrib code broken by a recent small interface change in D7, and
I think we should probably make announcements to this group when these
interface changes happen. I haven't figured out a better way of notifying
authors who might be affected.

PS: There is some new documentation on AJAX forms at
http://drupal.org/node/684846. Your review and suggestions are welcome.


Randy Fay
Drupal Development, troubleshooting, and debugging
randy at randyfay.com
+1  970.462.7450
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100326/e6ee6f35/attachment.html 

More information about the development mailing list