[Zope] redirection from within forms with submit button

Janko Hauser jh@comunit.de
Thu, 28 Mar 2002 09:59:54 +0100


On Thu, 28 Mar 2002 07:14:28 +0100
dvl <dvl@wanadoo.nl> 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?
> 
The redirection happens on the server the moment the page is rendered. 

> I want to make the redirection conditional on clicking the submit
> button.
The the redirection needs to happen in the form processing method not in
the form itself.

> 
> 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:
> 
> 
Here you are doing the redirecting in the in the form itself after it
get's called as a form processor.

> <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>
> 

Actually haven't looked at the other code, so perhaps I'm off.

__Janko