[support] How do I stop Drupal from running my callback twice? | drupal.org

Chris McGinlay chris at ascentsoftware.org.uk
Sun Jul 29 23:36:17 UTC 2007


On Thursday 26 July 2007 14:58, Eric McKenna wrote:
> I posted this on the module developers forum but no one had an answer
> so I'm trying again here:
>
> Here's my problem.
> Basically, I have form, on submission the form calls it's _submit
> function (mytest_form_submit), basic Forms API stuff. The _submit
> function returns a contructed URL to another callback in the system.
> I'm using a block with a form on it, and just putting the block in one
> of the columns.
>
> Now, Using the form from any page except the forms' results page works
> fine. After submission you are redirected with the return value from
> mytest_form_submit, to a results page.
>
> You can view the original post here, http://drupal.org/node/162054, it
> has my sample code which makes the issue easier to understand (i hope
> anyway :)
>
> Eric.

Would using a static flag variable provide an ugly hack to count the number of 
times the _submit() function runs?

Not the best solution probably:

function submit() {

	static $flag=0;
	if ($flag==0) {
		$flag++;
		//execute your function's code
	} 
	return;
}

HTH


More information about the support mailing list