{% extends 'base.html' %} {% autoescape conditional_xhtml_escape %} {% block content %} {% include 'modules/flash.html' %} {% module Template( 'modules/header.html', admin=admin, heading='%s / %s' % (admin.name, 'Edit' if obj else 'Add new'), back_button=True, add_button=True, absolute_url=admin.get_absolute_url(handler, obj) if obj else False ) %}
{% if form.errors %}

Error

Please correct the errors in the form before saving

{% end %}
{% module xsrf_form_html() %}
{% for field in form %}
{% if field.type == 'BooleanField' %} {% set input_class = 'custom-control custom-checkbox' %} {% elif field.type == 'RadioField' %} {% set input_class = 'custom-control custom-radio' %} {% elif field.type == 'SelectField' %} {% set input_class = 'custom-select' %} {% else %} {% set input_class = 'form-control' %} {% end %} {% if field.type in ['BooleanField', 'RadioField'] %}
{% if field.errors %} {{ mark_safe(field(class_='custom-control-input is-invalid')) }} {{ mark_safe(field.label(class_='custom-control-label')) }}
{{ field.errors[0] }}
{% else %} {{ mark_safe(field(class_='custom-control-input')) }} {{ mark_safe(field.label(class_='custom-control-label')) }} {% end %}
{% else %} {{ mark_safe(field.label) }} {% if field.errors %} {{ mark_safe(field(class_=input_class + ' is-invalid')) }}
{{ field.errors[0] }}
{% else %} {{ mark_safe(field(class_=input_class)) }} {% end %} {% end %}
{% end %}
{% end %}