我使用Colander和Deform實現了一個簡單的表單;不過,我希望覆蓋默認的樣式表並提供我自己的樣式表。但是,我不知道如何爲表單提供我自己的樣式。這裏是我使用的代碼:添加CSS到變形輸入表格
class Mapping(colander.Schema):
Firstname = colander.SchemaNode(colander.String(), css_class='deform-widget-with-style')
Lastname = colander.SchemaNode(colander.String(), css_class='deform-widget-with-style')
Email = colander.SchemaNode(colander.String(), css_class='deform-widget-with-style')
date = colander.SchemaNode(colander.Date(), widget = deform.widget.DatePartsWidget(), description = "content date")
class Schema(colander.Schema):
Age = colander.SchemaNode(colander.Integer(), css_class='deform-widget-with-style')
Firstname = colander.SchemaNode(colander.String(), css_class='deform-widget-with-style')
Lastname = colander.SchemaNode(colander.String(), css_class='deform-widget-with-style')
Email = colander.SchemaNode(colander.String(), css_class='deform-widget-with-style')
form = deform.Form(topList(),buttons=('submit',)).render(controlData)
當我運行這個,我得到一個計劃,默認的用戶形式。我怎樣才能提供我自己的模板樣式的按鈕和輸入框?任何建議或答案非常感謝。
目前的形式:
所需的輸入域風格:
所需的按鈕樣式:
當您忽略任何css_class屬性時,窗體是否使用默認引導樣式呈現? –
@SaschaGottfried謝謝你的評論。實際上,當css_class屬性被省略時,表單不會呈現默認的引導程序樣式。 – Ajax1234
如果是這種情況,請查看成功集成變形的金字塔應用程序。有幾個陷阱,但正如我在我的回答中所表明的那樣,這不是火箭科學,文檔是足夠的。 –