[Zope3-Users] Re: nextUrl(), passing state in formlib
juergen at kartnaller.at
Sun Sep 10 10:40:07 EDT 2006
I did it this way :
The Edit Form implementation :
template = ViewPageTemplateFile('club_add.pt')
The template ('club_add.pt') :
<div metal:use-macro="view/base_template/macros/main" >
<input type="hidden" name="referer" value="" tal:attributes="value
Hope this helps
Martin Aspeli wrote:
> I have an add form (and later, an edit form) that may be invoked from a
> particular view among a few choices. That is, the user can be at @@foo
> or @@bar, click "add X" or "edit Y".
> When the form is successfully submitted (i.e. validated) I want to send
> the user back to @@foo or @@bar depending on where they originally came
> Add forms (and my custom edit handler for the edit form) have a
> nextUrl() method to work out what the next URL should be. However, I
> need to pass the state of which page I came from along the requests.
> Using HTTP_REFERER doesn't work, because when it comes to the save
> button handler, the referer is the add form I was just on.
> One way would be to put a hidden field in the form that looked at the
> referer the first time it was rendered and then passed that state along
> subsequent requests. However, I really need a generalisable solution
> (there will be many of these add and edit forms for different objects).
> Having a custom pageform template for all of them (I can make them all
> use a custom base class) would be one option, but I'd rather avoid it if
> I could, since this'd need to repeat all the other code in the pageform
> that I'd rather not have to keep manually in sync when the original
> version changes or bugs are fixed.
> Is there some other way of passing this kind of "where did I originally
> come from" information along?
More information about the Zope3-users