How to enable ajax validation in CForm config file ?

I need create a form from config file with CForm, then how to enable ajax in the CForm config file ?

thanks.

Hi,

look here http://www.yiiframework.com/doc/guide/1.1/en/form.view




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

        'id'=>'top-websites-cr-form',

        'enableAjaxValidation'=>true,

        'clientOptions' => array(

      'validateOnSubmit'=>true,

      'validateOnChange'=>true,

      'validateOnType'=>false,

         ),

)); ?>



Actually if you not using CActiveForm I think you should write your own javascript for that…

or include manually the CActiveForm javascript and manipulate it… but better just create some FormModel

Kabinenkoffer nice to see my comment help :lol:

dckurushin: reuse, reuse, reuse

frist you should add ‘enableAjaxValidation’=>true in the widget CActiveForm also uncomment the line from the controller $this->performAjaxValidation($model);. Please confrim that there is function inside your controller

protected function performAjaxValidation($model)

{


	if(isset(&#036;_POST['ajax']) &amp;&amp; &#036;_POST['ajax']==='branch-form')


	{


		echo CActiveForm::validate(&#036;model);


		Yii::app()-&gt;end();


	}


}