strange validation problem

I have a module named as usergroup I am creating a controller and the controller code is

<?php

class ModulesController extends Controller

{

public &#036;userid='';


public &#036;usernameuser='';


public &#036;modules=array();





/**





 * @var mixed tooltip for the permission menagement


 */


/*public static &#036;_permissionControl = array(


				//'write'=&gt;'can invite other users.',


				'admin'=&gt;'can access all the modules',


				);*/


/**


 * @return array action filters


 */


public function filters()


{


	return array(


		'accessControl', // perform access control for CRUD operations


	);


}











public function beforeAction()


{


	&#036;obj=new SideMenu;


	&#036;modulesarray=&#036;obj-&gt;GetAllModules('0');


	&#036;this-&gt;modules=&#036;modulesarray;


	


	


	return true;


}





/**


 * Specifies the access control rules.


 * This method is used by the 'accessControl' filter.


 * @return array access control rules


 */


public function accessRules()


{


	return array(	array('allow',  // allow logged user to access the userlist page if the have admin rights on users or if the list is public


			'actions'=&gt;array('index'),


			'users'=&gt;array('@'),


		),


		array('allow',  // allow guest to view users profiles according to the configuration


			'actions'=&gt;array('view'),


			'users'=&gt;array('?','@'),


		),


		array('allow',  // allow a user tu open an update view just on their own accounts


			'actions'=&gt;array('AddModule'),


			'users'=&gt;array('?','@'),


			


		),


		


	);


	


}








public function actionAddModule()


{


	&#036;model=new UserGroupsModulesNew;


	&#036;allmodules=&#036;this-&gt;getAllModules();


	&#036;mainmodules=CHtml::listData(&#036;allmodules,'id','display_name');


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


	{


		


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


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


	}


	if(isset(&#036;_POST['UserGroupsModulesNew']))


		{	


		


			if(&#036;model-&gt;validate())


			{


				if(isset(&#036;_POST['UserGroupsModulesNew']['group_module']) &amp;&amp; &#036;_POST['UserGroupsModulesNew']['group_module']&#33;='' &amp;&amp; &#036;_POST['UserGroupsModulesNew']['group_module_old']=='')


				{


					


					//to update the tmp_images tablee


					&#036;modulegroupname=ucfirst(&#036;_POST['UserGroupsModulesNew']['group_module'].&quot;  Management.&quot;);


					&#036;sqlupdate = &quot;insert into usergroups_modules  set  display_name='&quot;.&#036;modulegroupname.&quot;',status='1',delete_flag='0',controller='&quot;.&#036;_POST['UserGroupsModulesNew']['group_module'].&quot;',parent_id=0&quot;;


					Yii::app()-&gt;db-&gt;createCommand(&#036;sqlupdate)-&gt;execute();


					//end of updating the images table


				}


				if(isset(&#036;_POST['UserGroupsModulesNew']['display_name']))


				{


					


					


					&#036;group_moduleid=Yii::app()-&gt;db-&gt;getLastInsertID();


					&#036;modulename=ucfirst(&#036;_POST['UserGroupsModulesNew']['display_name']);


					


					&#036;sqlupdate = &quot;insert into usergroups_modules  set  display_name='&quot;.&#036;modulename.&quot;',status='1',delete_flag='0',controller='&quot;.&#036;_POST['UserGroupsModulesNew']['group_module'].&quot;',parent_id='&quot;.&#036;group_moduleid.&quot;'&quot;;


					Yii::app()-&gt;db-&gt;createCommand(&#036;sqlupdate)-&gt;execute();


					//end of updating the images table


				}


				&#036;this-&gt;redirect(array('user/index'));


			}


			else


			{


				


				print_r(&#036;model-&gt;validate());


				print_r(&#036;model-&gt;getErrors());print_r(&#036;_POST);


				


				


				


			}


			


			


		}


	


	&#036;this-&gt;render('add',array('model'=&gt;&#036;model,'mainmodules'=&gt;&#036;mainmodules));


}





protected function performAjaxValidation(&#036;model)


{


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


	{


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


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


	}


}


public function getAllModules()


{


	&#036;criteria=new CDbCriteria;


	&#036;criteria-&gt;condition='status=:status and delete_flag=:delete_flag and parent_id=:parent_id';


	&#036;criteria-&gt;params=array(':status'=&gt;'1',':delete_flag'=&gt;'0',':parent_id'=&gt;0);


	&#036;getallmodules=UserGroupsModulesNew::model()-&gt;findAll(&#036;criteria);


	return &#036;getallmodules;


}

}

and the model code is

<?php

/**

  • This is the model class for table "usergroups_modules".

  • The followings are the available columns in table ‘usergroups_modules’:

  • @property integer $id

  • @property string $display_name

  • @property integer $display_order

  • @property integer $parent_id

  • @property string $status

  • @property string $delete_flag

*/

class UserGroupsModulesNew extends CActiveRecord

{

/**


 * Returns the static model of the specified AR class.


 * @return UserGroupsModules the static model class


 */


 


public &#036;group_module_old;


public &#036;group_module;


public &#036;submoduleurl;


public &#036;submodule;


public &#036;moduleurl;


public &#036;module; 


public static function model(&#036;className=__CLASS__)


{


	return parent::model(&#036;className);


}





/**


 * @return string the associated database table name


 */


public function tableName()


{


	 return Yii::app()-&gt;db-&gt;tablePrefix.'usergroups_modules';


}





/**


 * @return array validation rules for model attributes.


 */


public function rules()


{


	// NOTE: you should only define rules for those attributes that


	// will receive user inputs.


	return array(


		array('display_name', 'required'),


		


	);


}





/**


 * @return array relational rules.


 */


public function relations()


{


	// NOTE: you may need to adjust the relation name and the related


	// class name for the relations automatically generated below.


	return array(


	);


}








/**


 * @return array customized attribute labels (name=&gt;label)


 */


public function attributeLabels()


{


	return array(


		'id' =&gt; 'ID',


		'display_name' =&gt; 'Display Name',


		'display_order' =&gt; 'Display Order',


		'parent_id' =&gt; 'Parent',


		'status' =&gt; 'Status',


		'delete_flag' =&gt; 'Delete Flag'


	);


}





/**


 * Retrieves a list of models based on the current search/filter conditions.


 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.


 */


public function search()


{


	// Warning: Please modify the following code to remove attributes that


	// should not be searched.





	&#036;criteria=new CDbCriteria;





	&#036;criteria-&gt;compare('id',&#036;this-&gt;id);


	&#036;criteria-&gt;compare('display_name',&#036;this-&gt;display_name,true);


	&#036;criteria-&gt;compare('display_order',&#036;this-&gt;display_order);


	&#036;criteria-&gt;compare('parent_id',&#036;this-&gt;parent_id);


	&#036;criteria-&gt;compare('status',&#036;this-&gt;status,true);


	&#036;criteria-&gt;compare('delete_flag',&#036;this-&gt;delete_flag,true);





	return new CActiveDataProvider(&#036;this, array(


		'criteria'=&gt;&#036;criteria,


	));


}

}

and the view code is

<?php

$this->breadcrumbs=array(

Yii::t('userGroupsModule.general','Module Management'),

);

?>

<div id="userGroups-container">

&lt;div class=&quot;form&quot;&gt;


	&lt;?php &#036;form=&#036;this-&gt;beginWidget('CActiveForm', array(


		'id'=&gt;'user-groups-modules-form',


		'enableAjaxValidation'=&gt;true,


		'clientOptions'=&gt;array(


			'validateOnSubmit'=&gt;true,


			'validateOnType'=&gt;false,


			'validateOnChange'=&gt;false


		)


	)); ?&gt;


	&lt;div class=&quot;row&quot;&gt;


		&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'group_module'); ?&gt;


		&lt;?php echo &#036;form-&gt;textField(&#036;model,'group_module'); ?&gt;


		&lt;?php echo &#036;form-&gt;error(&#036;model,'group_module'); ?&gt;


	&lt;/div&gt;


	&lt;div class=&quot;row&quot;&gt;


		&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'group_module_old'); ?&gt;


		&lt;?php echo &#036;form-&gt;dropDownList(&#036;model,'group_module_old',&#036;mainmodules,array('prompt'=&gt;'--select--')); ?&gt;


		&lt;?php echo &#036;form-&gt;error(&#036;model,'group_module_old'); ?&gt;


	&lt;/div&gt;


	


	&lt;div class=&quot;row&quot;&gt;


		&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'display_name'); ?&gt;


		&lt;?php echo &#036;form-&gt;textField(&#036;model,'display_name'); ?&gt;


		&lt;?php echo &#036;form-&gt;error(&#036;model,'display_name'); ?&gt;


	&lt;/div&gt;


	&lt;div class=&quot;row&quot;&gt;	


		&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'moduleurl'); ?&gt;


		&lt;?php echo &#036;form-&gt;textField(&#036;model,'moduleurl'); ?&gt;


		&lt;?php echo &#036;form-&gt;error(&#036;model,'moduleurl'); ?&gt;


		


	&lt;/div&gt;


	&lt;div class=&quot;row&quot;&gt;


		&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'submodule'); ?&gt;


		&lt;?php echo &#036;form-&gt;textField(&#036;model,'submodule'); ?&gt;


		&lt;?php echo &#036;form-&gt;error(&#036;model,'submodule'); ?&gt;


	&lt;/div&gt;


	&lt;div class=&quot;row&quot;&gt;	


	


		&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'submoduleurl'); ?&gt;


		&lt;?php echo &#036;form-&gt;textField(&#036;model,'submoduleurl'); ?&gt;


		&lt;?php echo &#036;form-&gt;error(&#036;model,'submoduleurl'); ?&gt;


		


	&lt;/div&gt;





	&lt;div class=&quot;row buttons&quot;&gt;


		&lt;?php echo CHtml::submitButton('Add Module'); ?&gt;


	&lt;/div&gt;


	&lt;?php &#036;this-&gt;endWidget(); ?&gt;


&lt;/div&gt;

</div>

I don’t no the problem but when i use $model->validate it always returns false and $model->getErrors() always give errors.I have made loads of forms using the same code they all worled but strange it doesn’t work .Please help me out yii guysssssssssssssssssssssssssssssss I am stuck

sorry did was my stupid mistake