Andreas Reuleaux wrote:
> On Thu, Dec 15, 2005 at 02:41:33PM +0100, bruno desthuilliers wrote:
>
>>Hi all...
>>
>>I started playing with/digging into TG widgets and forms, and a few
>>things came to my mind that I felt I would share (not sure it's really
>>interesting but...).
>>
>>* first thing:
>>an interesting feature of Zope is the ability to have multiple submits
>>on the same form, with a naming scheme specifying the real action for
>>the form, ie:
>> <submit name="handlerMethodName:method" .... />
>>will use <current_controller>.handlerMethodName() as handler (ZPublisher
>>takes care of this dispatch)
>>
>>(err... not sure I'm very clear... sorry)
>>
>>This is definitively something I'd like to have in a TG forms/widgets
>>framework, and I thinks this could be easily implemented in TG (at least
>>with a default() handler doing the dispatch, but there may be better
>>options with cherryPy filters or whatever)
>>
>
> There is nothing special about multiple submit buttons
> (neither javascript nor any special Zope syntax needed), e.g.
>
> <form action="myaction"
> method="post">
> <input type="submit"
> name="change"
> value="Ändern"
> />
> <input type="submit"
> name="delete"
> value="Löschen"
> />
> </form>
>
> and in controllers.py
>
> @turbogears.expose()
> def myaction(self, change=None, delete=None):
> if change:
> ...
> elif delete:
> ...
> ...
Andreas, I of course know how to handle this case - and it's exactly
what I dont like. What I'd like (and that Zope provides) is :
<form action="mycontroller"
method="post">
<input type="submit"
name="change:method"
value="Change"
/>
<input type="submit"
name="delete:method"
value="delete"
/>
</form>
and in controllers.py
class MyController(...):
@turbogears.expose()
def change(self, **kw):
...
@turbogears.expose()
def delete(self, **kw):
...
Root.mycontroller = MyController()
--
bruno desthuilliers
développeur
[EMAIL PROTECTED]
http://www.modulix.com