3

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 ?

gibraltar
  • 1,678
  • 4
  • 20
  • 33

1 Answers1

5

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.

Anthony
  • 25,466
  • 3
  • 28
  • 57