Validation form builder

Hi,

I’m trying to validate a form, first client-side using ajax.

I’ve been looking at the tutorial and the code looks like this:

DbTable is called: tbl_clutter with 3 fields, ClutterId,Author,Comment

Does however not seem to work, anyone spot any faults in the code?

(_form.php a partial view of create.php)




<div class='form'>

<?php

	// Modellen är passad till denna vy redan via create.php

	// Påbörjar form widget, tilldelar $form CActiveForm	

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

        'id'=>'clutter-form',

        'enableAjaxValidation'=>true,

        'clientOptions' => array(

      'validateOnSubmit'=>true,

      'validateOnChange'=>true,

      'validateOnType'=>false,

         ),

)); 


    	

    	// Author kod, label, fält, felhantering

    	echo $form->labelEx($model,'Author');

	    echo $form->textField($model,'Author',array('size'=>30,'maxlength'=>30));

	    echo $form->error($model,'Author');

		

	    echo "<br/>";

	    

	    // Comment kod, label, fält , felhantering

	    echo $form->labelEx($model,'Comment');

	    echo $form->textArea($model,'Comment',array('size'=>500,'maxlength'=>500));

	    echo $form->error($model,'Comment'); 

	    

	    

		echo "<br/>" . CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');


$this->endWidget();?>

</div>



controller




	public function actionCreate()

	{

    	$model=new Clutter;

 

		if(Yii::app()->getRequest()->getIsAjaxRequest())

		{

			echo CActiveForm::validate(array($model));

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

		}	

	    $this->render('create',array(

	        'model'=>$model, // Model is passed to create.php View!

	    ));

	}



Right now the validation i get back is only server-sided.

If i press "submit/create" on my form it will go to the server and then display that the fields require content.

How do i get this to work on the client?