WTForms-How to prepopulate a textarea field?


Hi I have been trying to pepopulate a textareafield using something like this in the template.

{{form.content(value="please type content")}}

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?

2/25/2011 8:33:48 PM

Accepted Answer

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")

Then when you render:


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.

2/25/2011 9:02:00 PM

You can do it before rendering, something like: = 'please type content'

I'm new to WTForms though.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow