Property "CActiveForm.validateOnSubmit" is not defined.

The error i get is because of this code :




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

   'id'=>'saveUser',

   'enableAjaxValidation'=>true,

   'validateOnSubmit'=>true,

   'validateOnChange'=>false,

  'validateOnType'=>false,

)); ?>



If i take out the validateOnSubmit/validateOnChange/validateOnType properties, it works, however, it doesn’t load the javascript file that suppose to help on validation so that when i click submit, it just does a page refresh.

The documentation says that those properties can be set, so why i am getting the error ?

See here. You have to put those options into another clientOptions array.




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

   'id'=>'saveUser',

   'enableAjaxValidation'=>true,

   'clientOptions' => array(

      'validateOnSubmit'=>true,

      'validateOnChange'=>false,

      'validateOnType'=>false,

   ),

)); ?>



just 2 seconds ago i saw that, i don’t remember where i’ve seen them passed as main properties.

Also, seems like, the jquery.yiiactiveform.js is added to the page only if you add something like

<?php echo $form->error($model,‘first_name’);?>

into your form, else it’s not added .

This, of course needs a bit of tweaking to work, as i included jquery by default into my header, and had allot of scripts there, Yii just added those above mine so i had some js scripts, so i had to do a :




Yii::app()->clientScript->scriptMap=array('jquery.js'=>false);

Yii::app()->clientScript->coreScriptPosition=2;



In my controller in order to get rid of jquery and to move the active form script at the bottom of the page.