elbek
(Elbek Kamoliddinov)
February 18, 2011, 9:44am
1
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
elbek
(Elbek Kamoliddinov)
February 18, 2011, 10:52am
2
if i call $this->redirect("/"); framework calls /site/recovery and redirects (’/’). WHY?
tri
(tri - Tommy Riboe)
February 18, 2011, 11:41am
3
You’ve probably already read this post.
/Tommy
elbek
(Elbek Kamoliddinov)
February 18, 2011, 4:04pm
4
there is no ajax validation(); HELP!!!
mdomba
(Maurizio Domba Cerin)
February 18, 2011, 4:52pm
5
can you post your view file?
elbek
(Elbek Kamoliddinov)
February 19, 2011, 4:34pm
6
<?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
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
)); ?>
elbek
(Elbek Kamoliddinov)
February 20, 2011, 10:49am
10
I posted my action code and in my action i do not call to
performAjaxValidation($model);
elbek
(Elbek Kamoliddinov)
February 20, 2011, 10:56am
11
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.