Form attributes with Turbogears Widgets

The Widgets features in Turbogears allow you to easily insert forms in your page. But what if you want to control the behaviour and look of the form tag?

You need the “form_attrs” parameter:

`

importConfigForm = widgets.TableForm(
    fields = [
        widgets.TextField(name="name", label="Configuration Name:")
    ],
    submit_text="Import",
    form_attrs={'style':'display:none', 'id':'importForm'})

`

The above code creates a form and sets the “style” attribute to “display:none” and the “id” attribute to “importForm”.