Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web2py: Custom CSS class for custom form

Tags:

python

css

web2py

How do i specify the class of a custom web2py form? for e.g.

{{=form.custom.begin}}
Image name: <div>{{=form.custom.widget.name}}</div>
Image file: <div>{{=form.custom.widget.file}}</div>
Click here to upload: {{=form.custom.submit}}
{{=form.custom.end}}

How do i specify the CSS class for form ?

like image 552
gibraltar Avatar asked Mar 29 '26 18:03

gibraltar


1 Answers

If it's a SQLFORM, you can specify the class when you create the form:

form = SQLFORM(db.mytable, _class='myclass')

Otherwise, form.custom.begin simply produces the following HTML:

<form action="" enctype="multipart/form-data" method="post">

so instead of using form.custom.begin, you could simply enter that HTML (with your class added) directly into the template.

like image 195
Anthony Avatar answered Apr 02 '26 04:04

Anthony