WTForms-如何预填充textarea字段? [英] WTForms-How to prepopulate a textarea field?
问题描述
我一直在尝试使用某些方法填充textareafield 在模板中是这样的.
Hi I have been trying to pepopulate a textareafield using something like this in the template.
{{form.content(value="please type content")}}
这在字段为文本字段时有效,主要是因为html
接受<input type="text">
的值
但对于textarea来说这是行不通的...
有人可以帮我吗?
This works when the field is textfield primarily because the html
accepts value for <input type="text">
but the same does not work for textarea...
Can someone please help me with this?
推荐答案
对于textarea
小部件,您可以在字段构造函数中使用default
参数设置默认内容.
For textarea
widgets, you set the default content with the default
argument in your field constructors.
class YourForm(Form):
your_text_area = TextAreaField("TextArea", default="please add content")
然后在渲染时:
{{form.content()}}
WTForms将呈现默认文本.我还找不到在渲染时为文本区域指定默认文本的方法.
WTForms will render the default text. I have not been able to find a way to specify default text for the text area at render time.
这篇关于WTForms-如何预填充textarea字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!