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");

                        fclose($h);

                        $this->redirect("/");

                    }

                }

                else

                    $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.

/Tommy

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

can you post your view file?


<?php

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

$this->breadcrumbs=array(

	'Parolni tiklash',

);

?>


<h1>Parolni tiklash</h1>


<div class="form">

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

	'id'=>'pass-form',

	'enableAjaxValidation'=>true,

)); ?>


	<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>


	<div class="row buttons">

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

	</div>


<?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(

        'id'=>'pass-form',

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

)); ?>



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


 performAjaxValidation($model);

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.