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

前端 未结 9 1904
暗喜
暗喜 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:19

    For convenience, add this macro first.

    _formhelpers.html:

    {% macro render_field(field) %}
      
    {{ field.label }}
    {{ field(**kwargs)|safe }} {% if field.errors %}
      {% for error in field.errors %}
    • {{ error }}
    • {% endfor %}
    {% endif %}
    {% endmacro %}

    Import this macro and code in this way. it should work.

    {% from "_formhelpers.html" import render_field %}
    
    {{ render_field(form.content,rows=100, cols=100) }}

    Hope it helps !

提交回复
热议问题