gibraltar
gibraltar

Reputation: 1708

Web2py: Custom CSS class for custom form

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 ?

Upvotes: 3

Views: 2080

Answers (1)

Anthony
Anthony

Reputation: 25536

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.

Upvotes: 5

Related Questions