After having problems using CHtml::ajaxSubmitButton with a CActiveForm and ajaxValidationEnabled = true, where validation would not precede submission, and I found a race condition with validation triggered by focusout of current field when clicking the submit button (ex: unique validations will fail if record is saved before validation request is processed,) plus seeing many other people have faced this issue with only a handful unelegant solutions, I put together an extension of CActiveForm to wrap this up nicely.

This allows you to provide an afterSubmit param in the clientOptions and have the built in ajax validation work alongside ajax submission of forms as you’d expect it should.

Can’t post links yet so it’s on my github at / beezee / yii_cactiveajaxform