{% macro form_field(field) %}
    {% if field.widget.input_type == 'hidden' %}
    <div>{{ field(**kwargs) }}</div>
    {% else %}
    <div class="form-group{% if field.errors %} error{% endif %}">
        {{ field.label(class="control-label col-md-2 col-md-offset-1") }}
        <div class="col-md-2">
            {% set css_class = 'form-control ' + kwargs.pop('class', '') %}
            {{ field(class=css_class, **kwargs) }}
        </div>
        <span class="help-inline">
            {% for error in field.errors %}{{ error|e }}{% endfor %}
        </span>
    </div>
    {% endif %}
{% endmacro %}


{% macro form_field(field) %}
    {% if field.widget.input_type == 'hidden' %}
    <div>{{ field(**kwargs) }}</div>
    {% else %}
    <div class="form-group{% if field.errors %} has-error{% endif %}">
        {{ field.label(class="control-label col-md-2 col-md-offset-1") }}
        <div class="col-md-2">
            {% set css_class = 'form-control ' + kwargs.pop('class', '') %}
            {{ field(class=css_class, **kwargs) }}
        </div>
        <span class="help-block">
            {% for error in field.errors %}{{ error|e }}{% endfor %}
        </span>
    </div>
    {% endif %}
{% endmacro %}


Add error state to form field macro
Add error state to form field macro
