0
我想用WTForms(實際上燒瓶WTF)生成此:WTForms BooleanField可以有一個自定義值嗎?
<input id="attr" name="attr" type="checkbox" value="ALL"> Include all attributes
但如果有任何的方式來指定值BooleanField的一部分,我找不到它。如果我指定:
class MyForm(Form):
attr = BooleanField('attr', default=False, description="Include all attributes")
,並使其在模板:
{{ form.attr }} {{ form.attr.description }}
然後我得到
<input id="attr" name="attr" type="checkbox" value="y"> Include all attributes
BooleanField沒有一個 「選項」 或 「值」 屬性組。有什麼辦法可以強制它具有我選擇的價值(例如ALL
),而不僅僅是y
?
看看這裏http://stackoverflow.com/questions/19758112/pre-populating-a-booleanfield-as-checked-wtforms –
謝謝,但這似乎是一個討論如何有條件地使複選框活動(選中)時,而不是如何定製其「值」屬性。 –