Skip to content

Instantly share code, notes, and snippets.

@jasonamyers
Created January 9, 2013 17:07
Show Gist options
  • Save jasonamyers/4494865 to your computer and use it in GitHub Desktop.
Save jasonamyers/4494865 to your computer and use it in GitHub Desktop.
A VERY simple macro for rendering WTForms Fields in a bootstrap template
{% macro render_field(field) %}
<div {% if field.errors %}class="control-group error"{% else %}class="control-group"{% endif %}>
{% if field.name != "id" %}
<label class="control-label">{{ field.label }}</label>
{% endif %}
<div class="controls">
{{ field(**kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<span class="help-inline">{{ error }}</span>
{% endfor %}
{% endif %}
</div>
</div>
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment