Skip to content

Instantly share code, notes, and snippets.

@richardjpope
Created July 21, 2014 11:06
Show Gist options
  • Save richardjpope/30898d24ccaabf77c455 to your computer and use it in GitHub Desktop.
Save richardjpope/30898d24ccaabf77c455 to your computer and use it in GitHub Desktop.
WTForms bootstrap macro
{% macro render_field(field) %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{{ field.label(class_="control-label") }}
{{ field(class_="form-control", **kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<span class="help-block">{{error}}</span>
{% endfor %}
{% endif %}
</div>
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment