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

Eric Mckenna eric.mckenna at gmail.com
Tue Jul 31 12:26:32 UTC 2007


Chris McGinlay wrote:
> 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
>   
Actually, I think I'm just going to use an input button submitted with 
javascript instead of the forms api submit button.  That way I can take 
control of that particular
form away from drupal.  Not sure how else to do it. 


More information about the support mailing list