[Zope] redirection from within forms with submit button

Oliver Bleutgen myzope@gmx.net
Thu, 28 Mar 2002 09:42:03 +0100


dvl wrote:
> Hello Andy
> 
> 
>>Must admit I cant be bothered to read all this but some notes:
>>
> 
>>><input type="hidden" name="" value="<dtml-call
>>>"RESPONSE.redirect('toondecr2?datum=%s&teller=%s' %
>>>(datum,teller))">>">
>>>
> 
>>This is pointless, the page will never be rendered because it will instantly
>>do the redirect.
>>If you could refactor this a bit to more concise question...
>>
> 
> Gosh, you're harsh. I'll try.
> 
> Why the instant redirection?
> 
> I want to make the redirection conditional on clicking the submit
> button.
> 
> Why _does_ it work as I'd like it to when in a separate form (you don't
> have to read this;)?
> The following produces an almost empty webpage with just a submit button. The
> required action is only undertaken when the submit button is pressed:
> 
> 
> <form method="post" action="">
> <input type="submit" name="x" value="&gt;&nbsp;">
> <dtml-if x>
> <dtml-call "REQUEST.set('datum', _.str('1796/03/11'))">
> <dtml-call "REQUEST.set('teller', 5)">
> <input type="hidden" name="" value="<dtml-call
> "RESPONSE.redirect('toondecr2?datum=%s&teller=%s' %
> (datum,teller))">">
> </dtml-if>
> </form>
> 
> Cheers, Dirk

Dirk,
what you wrote is right, albeit a quite convoluted way to do this.
Let me rewrite this (ignore the wrapping):

<dtml-if x>
<dtml-call "REQUEST.set('datum', _.str('1796/03/11'))">
<dtml-call "REQUEST.set('teller', 5)">
<dtml-call "RESPONSE.redirect('toondecr2?datum=%s&teller=%s' % 
(datum,teller))">
</dtml-if>

<form method="post" action="">
<input type="submit" name="x" value="&gt;&nbsp;">
</form>

You see, writing the dtml-call in the hidden action has no effect, it 
seems like you got irritated there.
Could you perhaps reformulate what you want to do exactly?
Why do you want a submit button (since you can, as you did, also use 
normal a hrefs to pass parameters with a GET request)?


cheers,
oliver