[Zope] redirection from within forms with submit button

Oliver Bleutgen myzope@gmx.net
Tue, 02 Apr 2002 16:28:51 +0200


dvl wrote:
> Hello Oliver,
> 
> 
>>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>
>>
> 
> Thanks
> 
> 
>>You see, writing the dtml-call in the hidden action has no effect, it 
>>seems like you got irritated there.
>>
> ?? Irritated about my ignorance? Sure.

I sould have been more verbose. Of course, the dtml-call has an effect, 
namely the same independent from where it is written. It's just that 
writing it into the value attribute of the submit button doesn't give 
any extra functionality, like e.g. doing the call when the submit button 
is pressed.

> [snip]


>><dtml-call "RESPONSE.redirect('toondecr?datum=%s&teller=%s' %
>>
> (datum,teller))">>
> 
> and not in the method toondecr2 (which is a clone of toondecr with the
> submit form added)?
> 
> Why can i display the dtml-var's 'datum' and 'teller' in the submit
> button:
> <input type="submit" name="x" value="<dtml-var datum><dtml-var teller>">
> and yet get this error when clicking the submit button:
> Error Type: NameError
> Error Value: global name 'datum' is not defined
> 
> Just can't figure why the variables ain't passed.

Well, the code I posted does work (tested), so I'm quite sure your name 
error appears somewhere else. Could you use the code I posted in your 
method - because it's less confusing IMO - and, if it doesn't work, post 
the whole source code. I'm sure we'll find the problem.

cheers,
oliver