How to specify rows and columns of a <textarea > tag using wtforms

前端 未结 9 1972
暗喜
暗喜 2021-02-18 22:40

Constructing a wtforms\' TextAreaField is something like this:

content = wtf.TextAreaField(\'Content\', id=\"content-area\", validators=[validators.Required()])
         


        
9条回答
  •  佛祖请我去吃肉
    2021-02-18 23:12

    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() }}
    

提交回复
热议问题