[prev in list] [next in list] [prev in thread] [next in thread] 

List:       drupal-development
Subject:    Re: [development] D7 AJAX API change: Submit and Validation
From:       Randy Fay <randy () randyfay ! com>
Date:       2010-03-27 2:08:11
Message-ID: 15c957091003261908vef229d0h126dcefc46be61a2 () mail ! gmail ! com
[Download RAW message or body]

Sorry - the new AJAX Forms page is at http://drupal.org/node/752056

I'm hoping to expand upon that, and hoping that we can consolidate some more
of the D7 FAPI information as well.

The Examples module now has a gracefully degrading AJAX dependent dropdown
as well, pointed to by http://drupal.org/node/752056.

Thanks,
-Randy

On Fri, Mar 26, 2010 at 6:45 PM, Alex Bronstein <alex@craftyspace.com>wrote:

> Small clarification to this: #1 and #2 are true for when the triggering
> element is not a submit button or image button (or more precisely, when its
> #executes_submit_callback property isn't true, which by default is only for
> submit buttons and image buttons). So for example, when clicking a checkbox
> directly triggers AJAX. When an AJAX-enabled submit or image button triggers
> an AJAX submission, then by default, validation errors are reported and
> either the button's #submit handlers or the FORM_ID_submit() function do get
> executed as you're used to from D6 AHAH. In D7, a button can set #submit and
> #limit_validation_errors to empty arrays in order act the same as a
> non-button in this regard.
>
> Hopefully, D7 FAPI and AJAX documentation will help make all this clearer.
> Randy, can you please send the documentation link you intended to send in
> the PS. The issue URL got pasted instead.
>
> -Alex.
>
> Randy Fay wrote:
>
>> 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
>>
>> --
>> Randy Fay
>> Drupal Development, troubleshooting, and debugging
>> randy@randyfay.com <mailto:randy@randyfay.com>
>> +1  970.462.7450
>>
>>
>


-- 
Randy Fay
Drupal Development, troubleshooting, and debugging
randy@randyfay.com
+1  970.462.7450

[Attachment #3 (text/html)]

Sorry - the new AJAX Forms page is at <a \
href="http://drupal.org/node/752056">http://drupal.org/node/752056</a><br><br>I&#39;m \
hoping to expand upon that, and hoping that we can consolidate some more of the D7 \
FAPI information as well.<br> <br>The Examples module now has a gracefully degrading \
AJAX dependent dropdown as well, pointed to by <a \
href="http://drupal.org/node/752056">http://drupal.org/node/752056</a>.<br><br>Thanks,<br>-Randy<br><br><div \
class="gmail_quote"> On Fri, Mar 26, 2010 at 6:45 PM, Alex Bronstein <span \
dir="ltr">&lt;<a href="mailto:alex@craftyspace.com">alex@craftyspace.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Small clarification to this: #1 \
and #2 are true for when the triggering element is not a submit button or image \
button (or more precisely, when its #executes_submit_callback property isn&#39;t \
true, which by default is only for submit buttons and image buttons). So for example, \
when clicking a checkbox directly triggers AJAX. When an AJAX-enabled submit or image \
button triggers an AJAX submission, then by default, validation errors are reported \
and either the button&#39;s #submit handlers or the FORM_ID_submit() function do get \
executed as you&#39;re used to from D6 AHAH. In D7, a button can set #submit and \
#limit_validation_errors to empty arrays in order act the same as a non-button in \
this regard.<br>

<br>
Hopefully, D7 FAPI and AJAX documentation will help make all this clearer. Randy, can \
you please send the documentation link you intended to send in the PS. The issue URL \
got pasted instead.<br> <br>
-Alex.<br>
<br>
Randy Fay wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5"> If \
you&#39;re working with D7 AJAX Forms, you will be interested in an API change this \
week.<br> <br>
With <a href="http://drupal.org/node/684846" \
target="_blank">http://drupal.org/node/684846</a>, the AJAX triggering was \
refactored, and this has some effects on those of you using it:<br> <br>
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&#39;s submitting the entire form).<br> <br>
1. Fields don&#39;t get errors reported against them in the context of a \
single-element AJAX event. So for example, if you&#39;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.<br>

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

<br>
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&#39;t figured out a better way of notifying authors who might be \
affected.<br>

<br>
PS: There is some new documentation on AJAX forms at <a \
href="http://drupal.org/node/684846" \
target="_blank">http://drupal.org/node/684846</a>. Your review and suggestions are \
welcome.<br> <br>
-Randy<br>
<br>
-- <br>
Randy Fay<br>
Drupal Development, troubleshooting, and debugging<br>
</div></div><a href="mailto:randy@randyfay.com" \
target="_blank">randy@randyfay.com</a> &lt;mailto:<a href="mailto:randy@randyfay.com" \
target="_blank">randy@randyfay.com</a>&gt;<br> +1  970.462.7450<br>
<br>
</blockquote>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>Randy Fay<br>Drupal Development, \
troubleshooting, and debugging<br><a \
href="mailto:randy@randyfay.com">randy@randyfay.com</a><br>+1  970.462.7450<br><br>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic