{% macro render_form(form) %}


{{ form.csrf_token }}

{% for field in form %}

{% if field.type == 'BooleanField'%}
<div class="form-check">
  <label for="{{field.id}}" class="form-check-label">
    {{ field(class_="form-check-input") }}
    {{ field.label }}
  </label>
</div>
{% elif field.type != 'HiddenField' and field.type != 'CSRFTokenField' %}
{% set fclasses = 'form-control is-invalid' if field.errors else 'form-control' %}
<div class="form-group">
  <label for="{{ field.id }}" class="control-label">{{ field.label }}</label>
  {{ field(class_=fclasses) }}

  {% if field.errors %}
    {% for error in field.errors %}
      <div class="invalid-feedback">{{ error }}</div>
    {% endfor%}
  {% endif %}
</div>
{% endif %}

{% endfor %}

{% endmacro %}
