{% macro form_errors(form, hiddens=True) %} {%- if form.errors %} {%- for fieldname, errors in form.errors.items() %} {%- if bootstrap_is_hidden_field(form[fieldname]) and hiddens or not bootstrap_is_hidden_field(form[fieldname]) and hiddens != 'only' %} {%- for error in errors %}
{{error}}
{{ field.label.text }}
{% call _hz_form_wrap(horizontal_columns, form_type, True, required=required) %} {% for item in field -%}{{error}}
{{field.description|safe}}
{%- endif %} {%- elif field.type == 'SubmitField' -%} {# note: same issue as above - should check widget, not field type #} {% call _hz_form_wrap(horizontal_columns, form_type, True, required=required) %} {{field(class='btn btn-%s' % button_map.get(field.name, 'default'))}} {% endcall %} {%- elif field.type == 'FormField' -%} {# note: FormFields are tricky to get right and complex setups requiring these are probably beyond the scope of what this macro tries to do. the code below ensures that things don't break horribly if we run into one, but does not try too hard to get things pretty. #} {% else -%}{{error}}
{% endcall %} {%- endfor %} {%- elif field.description -%} {% call _hz_form_wrap(horizontal_columns, form_type, required=required) %}{{field.description|safe}}
{% endcall %} {%- endif %} {%- else -%} {{field.label(class="control-label")|safe}} {{field(class="form-control", **kwargs)|safe}} {%- if field.errors %} {%- for error in field.errors %}{{error}}
{%- endfor %} {%- elif field.description -%}{{field.description|safe}}
{%- endif %} {%- endif %}