On Thursday, April 11, 2019 at 10:03:34 AM UTC-7, Ben Lawrence wrote:
>
> HI
> I have a form with multiple submit buttons. It works.
>
> But to me it seems like a kludge. Is there a better way?
>
> Here is the controller where dictlist is just a list of dictionaries with 
> 'name' and 'id'
> So the part that seems kludgey to me is checking which button was pressed. 
> I do it by testing which of the buttons has the "Working..." value 
>

ITYM 'button name has the "Working" value'

that is the default web2py behaviour
>
>
What happens with the _value you set when you add the button?  Isn't that 
returned only for the button that is clicked?

 

>
>     buttons = []
>       for d in dictlist:
>         a = DIV( INPUT(_name = d['id'], _value = d['name'], _type = 
> 'submit'\
>                 , _class = "btn btn-outline-primary") )
>         buttons.append(a)
>
>     form = SQLFORM.factory(buttons = buttons)
>
>     if form.process().accepted:
>         for keys in form.vars:
>             # "working" is the web2py default text shown on the button 
> after press
>             if name_form.vars[keys][0:4] == "Work":  
>                redirect(URL('temp', vars=dict(who = keys) ))
>                break
>
>
>

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to