Problem with ajax validation and CActiveForm

Hi,

I have a problem related to CActiveForm and ajax validation. The problem is that the form validated even when clientOptions’=>array(‘validateOnSubmit’=>true,). As I have understood it the validateonsubmit should stop validation until the form i submitted. As it is now the form validates when a text field is loosing focus.

Any pointers would be much appreciated.

This is my form:




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

        'enableAjaxValidation'=>true,

	'id'=>'login-form',

	'clientOptions'=>array(

		'validateOnSubmit'=>true,

	),

)); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<div class="row">

		<?php echo $form->labelEx($model,'username'); ?>

		<?php echo $form->textField($model,'username'); ?>

		<?php echo $form->error($model,'username'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'password'); ?>

		<?php echo $form->passwordField($model,'password'); ?>

		<?php echo $form->error($model,'password'); ?>

	</div>


	<div class="row rememberMe">

		<?php echo $form->checkBox($model,'rememberMe'); ?>

		<?php echo $form->label($model,'rememberMe'); ?>

		<?php echo $form->error($model,'rememberMe'); ?>

	</div>


	<div class="row buttons">

		<?php echo CHtml::submitButton('Login'); ?>

	</div>

<?php $this->endWidget(); ?>



And this is my controller:


public function actionLogin()

	{

		$this->layout = "//layouts/column1_2";

                $model=new LoginForm;


		// if it is ajax validation request

		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')

		{

			echo CActiveForm::validate($model);

			Yii::app()->end();

		}


		// collect user input data

		if(isset($_POST['LoginForm']))

		{

			$model->attributes=$_POST['LoginForm'];

			// validate user input and redirect to the previous page if valid

			if($model->validate() && $model->login())

                                if (Yii::app()->user->returnUrl == Yii::app()->homeUrl){

                                    $this->redirect (array('work/create'));

                                }

                                else

                                    $this->redirect(Yii::app()->user->returnUrl);

		}

		// display the login form

		$this->render('login',array('model'=>$model));

                

	}




'clientOptions'=>array(

       'validateOnChange'=>false,

       'validateOnSubmit'=>true,

),

Thank you!! So simple I feel quite ashamed of my self!