Hi Tom,

Thanks for replying.

The problem is that kw['submit'] results in a KeyError exception.   
Inspecting the kw dict shows there isn't element in the dict  
corresponding to the submit button itself.

Any ideas?

Jamie

On 26 Aug 2009, at 13:41, Crusty wrote:

> Hey Jamie,
>
> you answered your own question, or what is the problem with that?
> It's done almost exactly the way you wrote it, except for some ugly
> pecularities of how TW sets the value attribute, which is a bit  
> twisted.
>
> Could you be more specific what goes wrong on your code?
>
> Tom
>
> On Tue, Aug 25, 2009 at 4:40 PM, Jamie Bullock 
> <[email protected] 
> > wrote:
>
>
> Hi,
>
> I'm sure this is really simple, but I'm stumped right now.
>
> Basically, I want a form with multiple buttons to be processed by a
> single handler, but run sections of handler code conditionally
> depending on which button was pressed.
>
> class MyForm(TableForm):
>    class fields(WidgetsList):
>        fooButton = SubmitButton(attrs={'value':'foo'})
>        barButton = SubmitButton(attrs={'value':'bar'})
> new_my_form = MyForm("new_my_form")
>
> Then:
>
> def post(self, *arg, **kw):
>
>    if kw['submit'] == 'foo':
>          do_something()
>    if kw['submit'] == 'bar':
>          do_something_else()
>
> Is this possible?
>
> Jamie
>
>
>
>
>
>
>
>
>
> >


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