{% 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}}

{%- endfor %} {%- endif %} {%- endfor %} {%- endif %} {%- endmacro %} {% macro form_field(field, form_type="basic", horizontal_columns=('lg', 2, 10), button_map={}, form_errors=False) %} {% if form_errors %} {% if field.errors %} {% set field_classes = 'is-invalid' %} {% else %} {% set firld_classes = 'is-valid' %} {% endif %} {% else %} {% set field_classes = '' %} {% endif %} {% if form_type == 'horizontal' %} {% set offset = ' offset-' ~ horizontal_columns[0] ~ '-' ~ horizontal_columns[1] %} {% set col1 = ' col-' ~ horizontal_columns[0] ~ '-' ~ horizontal_columns[1] %} {% set col2 = ' col-' ~ horizontal_columns[0] ~ '-' ~ horizontal_columns[2] %} {% endif %} {% if field.type == 'BooleanField' %}
{% if form_type == 'horizontal' %}
{% endif %}
{{ field(class_='form-check-input ' ~ field_classes) }} {{ field.label(class_='form-check-label') }}
{% if form_type == 'horizontal' %}
{% endif %} {% elif field.type == 'RadioField' %}
{% if form_type == 'horizontal' %}
{{ field.label }}
{% endif %} {% for key, value in field.choices %}
{% endfor %} {% if form_type == 'horizontal' %}
{% endif %} {% elif field.type == 'FileField' %}
{{ field(class_='custom-file-input' ~ field_classes) }} {{ field.label(class_='custom-file-label') }}
{% elif field.type == 'SubmitField' %} {{ field(class='btn btn-%s' % button_map.get(field.name, 'dark')) }} {% elif field.type == 'CSRFTokenField' %} {{ field }} {% else %}
{{ field.label(class_=col1) }} {{ field(class_='form-control ' ~ field_classes ~ col2) }} {% endif %} {% if field.description %} {{ field.description }} {% endif %} {% if field.errors %} {% for error in field.errors %}
{{ error }}
{% endfor %} {% endif %}
{% endmacro %} {% macro quick_form(form, action="", method="post", extra_classes=None, role="form", form_type="basic", horizontal_columns=('lg', 2, 10), enctype=None, button_map={}, id="", novalidate=False, render_kw={}) %} {%- set _enctype = [] %} {%- if enctype is none -%} {%- for field in form %} {%- if field.type == 'FileField' %} {%- set _ = _enctype.append('multipart/form-data') -%} {%- endif %} {%- endfor %} {%- else %} {% set _ = _enctype.append(enctype) %} {%- endif %}