1
使用wtforms我想格式化下面的表單。所以我有evrything工作,但我不需要'FormField'被包裹在HTML表 - 所以如何繞過/重寫呢?在WTForms中覆蓋html格式的FormField
class WeekdayHoursForm(BaseForm):
hours = [(str(x+1), str(x+1)) for x in range(12)]
mins=[('00',':00'),('15',':15'),('30',':30'),('45',':45')]
fromHour = SelectField('',choices=hours)
fromMin = SelectField('',choices=mins)
toHour = SelectField('',choices=hours)
toMin = SelectField('',choices=mins)
closed = BooleanField('Closed','0')
class AddListingForm(BaseForm):
monday = FormField(WeekdayHoursForm)
tuesday = FormField(WeekdayHoursForm)
etc...
我查看
<div class="wrapper-block weekday" id="mon">
{{ form.monday.label }} {{ form.monday() }}
</div>
<div class="wrapper-block weekday" id="tues">
{{ form.tuesday.label }} {{ form.tuesday() }}
</div>
我省略了生成的HTML,但如果需要,我可以將其粘貼 - 我知道wtforms FormField採用了「TableWidget」,但我不知道在哪裏可以將它設置爲'with_table_tag = False'
?
謝謝 - 我諮詢了文檔,但仍然不知道在哪裏/如何在widget傳遞。 – rebelbass 2012-07-20 02:58:30