Andre Meyer schrieb:
> Hi all
> 
> What I want to do is to have a form with multiple actions in html. The 
> form tag allows only one action, but one can define multiple submit 
> buttons. Here is how I handle this for now, but it does not look very 
> elegant. What would be a more elegant way to handle this case in the 
> controller? How about adding checkboxes for handling a whole bunch of 
> tags in the list?
> 
> thanks for hints
> cheers
> andré
> 
> 
> <form method="post" action="/edit_tag">
>     <input type="hidden" name="tag_id" value="${tag.id <http://tag.id>}" />
>     <input type="text" size="64" name="name" value="${tag.name 
> <http://tag.name>}" />
>     <input type="submit" name="update_tag" value="update" />
>     <input type="submit" name="delete_tag" value="delete" />
> </form>
> 
> 
> @expose()
> def edit_tag(self, tag_id, name, *args, **kw):
>     referer = request.headerMap.get ("Referer", "/")
>     if "update_tag" in request.params:
>         self.update_tag(tag_id, name)
>     elif "delete_tag" in request.params:
>         self.delete_tag(tag_id)
> 

Give your buttons the same name, e.g. action. Then you can do something 
like this:

@expose()
def edit_tag(self, action=None, tg_errors=None, *kwargs):
     return getattr(self, "action_%s" % action)(tg_errors=tg_errors, 
**kwargs)

Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to