More then one buttons on form

59 views
Skip to first unread message

Константин Комков

unread,
May 22, 2019, 4:12:19 AM5/22/19
to web...@googlegroups.com
Web2py automatically add event listeners and class="btn" for button. What if my form contain more then one button or I don't want use that class? Usually I have used input type="button" without form in that case, but now text in my button may contain 2 rows and I can't use input becouse it inline element. How can I delete all web2py event listeners for buttons?
For class I do next:
el = document.getElementById("bak");
el.classList.remove("btn");
In my case I want use form with two button which redirect user on one page but that buttons have different values. Hm.. may I use two forms?

Константин Комков

unread,
May 22, 2019, 9:30:23 AM5/22/19
to web2py-users
I use two forms now as I think it is not good. After button was pushed height of them was changed (btns.png).

btns.png

João Matos

unread,
May 22, 2019, 11:55:42 AM5/22/19
to web2py-users

Christian Varas

unread,
May 22, 2019, 9:29:22 PM5/22/19
to web...@googlegroups.com
Hi, well what I do to change some attributes in the forms is modifiying the form before to be returned/rendered:
You can access to the elements in the  form like a list
Ex:

form = SQLFORM.factory(Field('hoho'),
                                               Field('haha')
)

form[0][1][1]['_class'] = "nothing"

return dict(form=form)

This Will change the class of the last <td> tag from "w2p_fw" to "nothing"

For a massive replace maybe Javascript is the best way.
 
Cheers!

El mié., 22 de may. de 2019 04:12, Константин Комков <firean...@gmail.com> escribió:
Web2py automatically add event listeners and class="btn" for button. What if my form contain more then one button or I don't want use that class? Usually I have used input type="button" in that case, but now text in my button may contain 2 rows and I can't use input becouse it inline element. How can I delete all web2py event listeners for buttons?
For class I do next:
el = document.getElementById("bak");
el.classList.remove("btn");


--
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 web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/e4a04290-d79f-4af0-9607-40dd9b120046%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Константин Комков

unread,
May 23, 2019, 3:07:13 AM5/23/19
to web2py-users
João Matos, Christian Varas thank you!
Reply all
Reply to author
Forward
0 new messages