two times calls cantroller action

I have siteContoller and she has a actionRecovery action, When i submit form he is called two times

public function actionRecovery()


        $model = new PasswordRecoveryForm();

        if (isset($_POST['PasswordRecoveryForm'])) {

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

            if ($model->validate()) {

                if (Utils::validate_email($model->username_email))

                    $user = User::model()->find('email=:email', array(':email' => $model->username_email));

                if ($user->email) {

                    if (PasswordRecoveryForm::sendRecoveryEmail($user)) {

                        Yii::app()->user->setFlash('success', 'Sizning pochtangizga email yuborildi');

                        $h = fopen("new.txt",'a+');

                        fwrite($h, "entered");






                    $model->addError('username_email', "Email hato kiritilgan!");



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


for testing i use fwrite fwrite($h, "entered"); php writes two time in file. why? help me

if i call $this->redirect("/"); framework calls /site/recovery and redirects (’/’). WHY?

You’ve probably already read this post.


there is no ajax validation(); HELP!!!

can you post your view file?


$this->pageTitle=Yii::app()->name . ' - Login';


	'Parolni tiklash',



<h1>Parolni tiklash</h1>

<div class="form">

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



)); ?>

	<div class="row">

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

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

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


	<div class="row buttons">

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


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

</div><!-- form -->

it is my view file

Yes, it is.

any help?

Tri already told you… set your ajaxvalidation= false like so

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


        'enableAjaxValidation'=>false, // HERE YOU HAD set to TRUE

)); ?>

I posted my action code and in my action i do not call to


Vauu i am sorry, It helped me already, but no i saw it.

Thanks big

The problem is not on your controller is in your view (that function in your controller that you say you are not using, checks whether the request was ajax or not, thats all, if you do not check that and you maintain the ‘enableAjaxValidation’=>true on your view, you will surely have the action called twice: one ajax and one on submission…

Again, your problem is in the view as it seems.