Here is my code:
public function actionPostTest()
{
if(isset($_POST['Test']))
{
$model = new Test();
$model->attributes = $_POST['Test'];
if($model->save())
{
$this->redirect('postTest');
}
}
$this->render('posttest', array('model'=>new Test()));
}
This is saving the data which coming from a form twice to the database.
What is wrong?
Try disabling ajax validation.
Set
enableAjaxValidation
tofalse
in that view.Actually there POST happens two times. First Ajax validation and second form submit. You can confirm it by using httpfox in firefox.