Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Extension of CActiveForm that submits via Ajax and uses Ajax validation
JavaScript PHP
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Using CHtml::ajaxSubmitButton with a CActiveForm doesn't really mesh well with ajax validation. Validation is not performed before submission, and clicking submit straight from a form field can trip a seperate, simultaneous call to validate alongside submission, creating a race condition (ex: unique validations will fail if record is saved before validation request is processed.)

The issue is discussed here -

Qiang Xue suggests an alternative to CACtiveForm to handle these scenarios, which is what this extension does.

Drop the activeajaxform folder in your extensions folder add the path to your import listing and use according to the example below:

<div class="add_tag pull-left">
    <?php $form=$this->beginWidget('CActiveAjaxForm', array(
        'clientOptions' => array(
            'afterSave' => 'js:function(result, form) {
                                form.each(function() { this.reset(); });}',
            'onSubmit' => 'js:function() { //some extra stuff to do when form is submitted }',
        'action' => CHtml::normalizeURL(array('tag/create')),
        'htmlOptions' => array('class' => 'form-inline'),
    )); ?>
        <div class="control-group">

                echo $form->labelEx($newTag, 'name',
                                array('class' => 'control-label', 'label' => 'New Tag: '));
                echo $form->textField($newTag, 'name');
                echo $form->error($newTag, 'name');
                echo CHtml::submitButton('Add Tag');

    <?php $this->endWidget(); ?>
Something went wrong with that request. Please try again.