Constructing a wtforms' TextAreaField is something like this:
content = wtf.TextAreaField('Content', id="content-area", validators=[validators.Required()])
How can I specify the number of rows and columns associated with this textarea?
You are not supposed to do it in the place where you declare the widget. You have do it in the template. For eg:
{{form.content(rows='50',cols='100')}}
Need to ensure the rows and cols are specified as a string.
Much simpler; use render_kw
argument when creating the field:
port = IntegerField(u"HTTP port", validators=[DataRequired(), NumberRange(1025, 65535)], render_kw={'class': 'form-control'})
mytextarea = TextAreaField(u"Content", render_kw={'class': 'form-control', 'rows': 5})
And then render the file:
{{ field() }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With