[HINT] Nesting forms correctly.

Well, it took me practically the whole day to figure out why an ajaxSubmitButton was not posting the form to my AJAX action. I post this in order to save you some headaches in case you arrive to the same scenario. Lets say you have this in a view (PHP in pseudocode):


<div>

<CActiveForm>

   <div>

  	<TextBox>

   </div>

</div>

<div>

   <AjaxSubmitButton>

</div>

</CActiveForm>

The Javascript code generated by AjaxSubmitButton uses


jQuery(this).parents("form").serialize()

So, if you nest the divs and form as I did, jQuery won’t find the <form> parent, thus the $_POST value will be empty. You need to nest things correctly:




<div>

<CActiveForm>

   <div>

  	<TextBox>

   </div>

<div>

   <AjaxSubmitButton>

</div>

</CActiveForm>

</div>

I hope this helps someone.

NOTE: moved to Tips instead of general section