{% macro form_field(field, autofocus) %} {%- if field.type == 'BooleanField' %}
{{ field(class='form-check-input') }} {{ field.label(class='form-check-label') }}
{%- elif field.type == 'RadioField' %} {{ field.label(class='form-label') }} {%- for item in field %}
{{ item(class='form-check-input') }} {{ item.label(class='form-check-label') }}
{%- endfor %} {%- elif field.type == 'SelectField' %} {{ field.label(class='form-label') }} {{ field(class='form-select mb-3') }} {%- elif field.type == 'TextAreaField' %}
{{ field.label(class='form-label') }} {% if autofocus %} {{ field(class='form-control' + (' is-invalid' if field.errors else ''), autofocus=True) }} {% else %} {{ field(class='form-control' + (' is-invalid' if field.errors else '')) }} {% endif %} {%- for error in field.errors %}
{{ error }}
{%- endfor %}
{%- elif field.type == 'SubmitField' %} {{ field(class='btn btn-primary mb-3') }} {%- else %}
{{ field.label(class='form-label') }} {% if autofocus %} {{ field(class='form-control' + (' is-invalid' if field.errors else ''), autofocus=True) }} {% else %} {{ field(class='form-control' + (' is-invalid' if field.errors else '')) }} {% endif %} {%- for error in field.errors %}
{{ error }}
{%- endfor %}
{%- endif %} {% endmacro %} {% macro quick_form(form, action="", method="post", id="", novalidate=False) %}
{{ form.hidden_tag() }} {%- for field, errors in form.errors.items() %} {%- if form[field].widget.input_type == 'hidden' %} {%- for error in errors %}
{{ error }}
{%- endfor %} {%- endif %} {%- endfor %} {% set ns = namespace(first_field=true) %} {%- for field in form %} {% if field.widget.input_type != 'hidden' -%} {{ form_field(field, ns.first_field) }} {% set ns.first_field = false %} {%- endif %} {%- endfor %}
{% endmacro %}