{% from "_icon.html" import icon %} {% macro errors(items) %} {% for error in items %} {{ error }} {% endfor %} {% endmacro %} {% macro attachment_field(entity, class='form-control') %} {{ entity.label(class_="form-label")}} {% if entity.data.id %}
File
{{ icon('trash') }}
{{ entity(class_="form-control", disabled=True, type="text") }}
Only one attachment is supported at a time.
{{ errors(entity.errors) }} {% else %} {{ entity.label(class_="form-label")}} {{ entity(class_="form-control", **kwargs) }} {% if entity.description %}
{{ entity.description }}
{% endif %} {{ errors(entity.errors) }} {% endif %} {% endmacro %} {% macro field(entity, class='form-control') %} {% if entity.widget.input_type == "checkbox" %}
{{ entity(class="form-check-input", **kwargs) }} {{ entity.label(class="form-check-label") }}
{% elif entity.widget.input_type == "file" %} {{ attachment_field(entity, class=class)}} {% else %} {{ entity.label(class_="form-label")}} {{ entity(class_="form-control", **kwargs) }} {% endif %} {% if entity.description %}
{{ entity.description }}
{% endif %} {{ errors(entity.errors) }} {% endmacro %}