afterValidateAttribute not called on success

My form validates all fields successfully, but I want to remove the CSS error class when everything is OK.

All of my fields validate on change, but the below only pops up a dialog saying "Got a problem!", even when I correct any errors. If I erase the field and type in some other garbage, it reports a problem again.

I even moved the alert call out of the conditional, but it never resolves if I change the field to hold the correct content.

Since success is never reported, the error style on the field never goes away.

Why is this happening?




$form = $this->beginWidget('CActiveForm', array(

    'id'=>'treeForm',

    'enableAjaxValidation'=>true,

    'enableClientValidation'=>true,

    'clientOptions'=>array(

        'validateOnChange'=>true,

    )

));


//...stuff was here...


echo $form->error($model,'odds_sj', array(

    'afterValidateAttribute' => 'js:function(form, attribute, data, hasError)

    { 

        if (!hasError)

        {

            alert("All good!");

        }

        else

        {

            alert("Got a problem!");

        }

    }'

));

echo $form->error($model,‘odds_sj’, array(

'afterValidateAttribute' => 'js:function(form, attribute, data, hasError)


{ 


    if (!hasError)


    {


        alert("All good!");


    }


    else


    {


        alert("Got a problem!");


    }


}'

));

contain Error Code of Previous State of Submit Keep refresh These Form Update

I’ve got this behaviour only once, right after afterValidateAttribute was added.

After one page refresh I’ve got it working correctly now. A bit strange, but maybe it’s browser’s cache?

BTW, there were several CActiveForm bugs in 1.1.9 yii version, but there’re not the same as you describe.