On 4/6/06, Robin Haswell <[EMAIL PROTECTED]> wrote:
>
> Hey guys
>
> I think this has been asked before, but the answer was a .9a1 hack and
> someone mentioned it would be a lot easier => .9a2. Basically I'm using
> TableForms and I would like to have more than one submit button (Edit,
> Delete) on one line for my CRUD pages. Ideally they'd have the same name
> ("action") and one of them would have an onclick action. Could someone
> give me a hand with this?

Not an answer to your question, but just a tip: I usually use
different names for submit buttons, because if I decide later to
change the button label in the view (e.g. different language), i dont
have to change the code in the controller. And the Python code looks
nicer IMHO:

def save(self, edit=None, delete=None, **data):
    if edit:
        # something
    elif delete:
        # something

Also, it might be not a good thing to name a form element "action",
because you loose the ability to refer to "action" property of the
form in Javascript.

Ksenia.

>
> Cheers :-)
>
> -Rob
>
> [OT]:
>
> Damn I wish Python has a switch/case structure.
>
> switch action:
>         case "Edit":
>                 # something
>         case "Delete":
>                 # something else
>         case "Something Else":
>                 # etc
>
> ..is a lot nicer than..
>
> if action is "Edit":
>         # something
> if action is "Delete":
>         # something else
> if action is "Something Else":
>         # etc
>
> DRY!
>
> :-)
>
> -Rob
>
> >
>

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

Reply via email to