Action called twice when using js with form

Hi all,

I have this very odd problem.

This is my view:

<?php echo CHtml::beginForm('','',array('target'=>'PPDGFrame')); ?>

<?php echo CHtml::hiddenField('expType','light');  ?>

<?php echo CHtml::hiddenField('paykey',$paykey);  ?>

<?php echo CHtml::submitButton('Submit',array('id'=>'submitBtn')); ?> 

<?php echo CHtml::endForm(); ?> 


//	Event for paypal buy now

	$cs = Yii::app()->getClientScript();  



	  'var dgFlow = new PAYPAL.apps.DGFlow({ trigger: "submitBtn" });





The $paykey is generated when the action is called and stored in a table. I noticed that for every the page loads the action is called twice! So there are two rows of paykey on each page load.

Now, if you so much as change the trigger: "submitBtn" to something else, like trigger: "none" - this does not happen. I have no idea why yii calls the action twice, maybe it has to do with Ajax?

Can anyone think of something here?


Are you using ajax to submit the form?

Check firebug how many calls there are being made


I am not using Ajax to submit. The paypal JS is opening a new frame with clicking on the submit.

How do I check how many called are being made?

You could use SESSION vars to keep track of actions (simple but effective)

I would first check if the javascript is inlcuded correctly (only once)