The correct answer is as follows:
abc = TextField('abc', validators=[Required(), Length(min=3, max=30)], description="test")
As you can read in the documentation:
description – A description for the field, typically used for help text.
Then in your template:
{% import 'forms.html' as forms %} {% for field in form %} {{ forms.render_field(field) }} {% endfor %}
Where render_field is the macro that is defined in forms.html:
{% macro render_field(field) -%} {% if field.type == 'CSRFTokenField' %} {{ field }} {% if field.errors %} <div class="warning">You have submitted an invalid CSRF token</div> {% endif %} {% elif field.type == 'HiddenField' %} {{ field }} {# any other special case you may need #} {% else %} <div class="form-group"> <label for="{{ field.label.field_id }}" class="col-sm-2 control-label">{{ field.label.text }}</label> <div class="col-sm-10"> {{ field(placeholder=field.description) }} {% if field.errors %} <div class="alert alert-danger" role="alert"> {% for err in field.errors %} <p>{{ err|e }}</p> {% endfor %} </div> {% endif %} </div> </div> {% endif %} {%- endmacro %}
Drachenfels Apr 21 '15 at 13:15 2015-04-21 13:15
source share