Action being called twice?

I have a weird issue that just started happening:

When I submit a form, the action is called twice, for example:

In the form

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



)); ?>

In the controller

	public function actionCreate()


		$model=new Group;

		// Uncomment the following line if AJAX validation is needed






                        if($model->hasAttribute('AccountID')) $model->AccountID = Security::getAccountID();









                    Yii::app()->user->setFlash('over','<b>Your account is over its limit!<b><br><br>' .  CHtml::link('Click here to view your account limits.', $this->createUrl('account/index')));







I have searched for the issue and I know many people have resolved the issue by setting in the form


and un-commenting the line in the controller


I have tried this, and it actually makes the problem worse, I end up with 10+ submissions instead of two.

Should note…

The server this is happening on is on a hosted provider, the code works perfectly fine on my local computers, and it has in the past worked fine on the hosted provider, the issue just started occurring. The provider tells me nothing on the server has changed, and my code has not changed.


Are you saying you get 2 new Groups? Do you get redirected to the latest group view afterwards?

That is correct.

if I make a group named "test" I end up with two groups named "test" and it redirects to the 2nd one.

And in an odd plot twist, it is automatically working again…I have changed nothing in my code. I will try it on the work network (where the issue was happening) in the morning.

Tested at work this morning…still double posting.

I am clueless on how to fix this, but it is a show stopper -

Works fine at home, double posts from work (tested on multiple computers and multiple browsers)

Update - on IE it will post it three times.

*** UPDATE ***

In case anyone is following this thread and having similar issues, I solved the problem

In the controller add:

public function actionCreate()


   if(Yii::app()->getRequest()->getIsAjaxRequest()) Yii::app()->end();

//Rest of your code below

In the form, enable ajax (even if you don’t need it)

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



)); ?>

This was only happening at work, and on all computers at work (multiple operating systems and browsers)

Oddly enough the Gii generated code was making things much worse, for example,

public function actionCreate()


   $model = new MyModel();


   // ... your code


The above would cause 10+ records to be saved.

This might make a compelling case for me to move to Yii 2 - but after spending 6+ months developing the site, I am in no big hurry to start over.

Wait, are you trying to do form submissions via ajax? I see no reason why any of your sample code would cause multiple database entries to be saved, unless you are trying to do stuff via ajax and you are doing multiple requests accidentally. Check your browser’s network tab if possible to see if multiple requests are being called