public function actionCreate()
{
$model=new Group;
// Uncomment the following line if AJAX validation is needed
//$this->performAjaxValidation($model);
if(isset($_POST['Group']))
{
$model->attributes=$_POST['Group'];
if($model->hasAttribute('AccountID')) $model->AccountID = Security::getAccountID();
if($model->save())
$this->redirect(array('view','id'=>$model->idGroup));
}
if(BillingHelper::hasMaxGroups())
{
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')));
}
$this->render('create',array(
'model'=>$model,
));
}
I have searched for the issue and I know many people have resolved the issue by setting in the form
‘enableAjaxValidation’=>true
and un-commenting the line in the controller
//$this->performAjaxValidation($model);
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.
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.
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