finetune Form presentation

Ease the development of future forms
Adapt tenant and user forms
This commit is contained in:
Josako
2024-04-26 18:17:42 +02:00
parent 9c1a3e8f55
commit e8f97b7317
9 changed files with 106 additions and 79 deletions

View File

@@ -0,0 +1,24 @@
{% macro render_field(field, disabled_fields=[], exclude_fields=[]) %}
{% set disabled = field.name in disabled_fields %}
{% set exclude_fields = exclude_fields + ['csrf_token', 'submit'] %}
{% if field.name not in exclude_fields %}
{% if field.type == 'BooleanField' %}
<div class="form-check">
{{ field(class="form-check-input", type="checkbox", id="flexSwitchCheckDefault") }}
{{ field.label(class="form-check-label", for="flexSwitchCheckDefault", disabled=disabled) }}
</div>
{% else %}
<div class="form-group">
{{ field.label(class="form-label") }}
{{ field(class="form-control", disabled=disabled) }}
{% if field.errors %}
<div class="invalid-feedback">
{% for error in field.errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
{% endif %}
{% endmacro %}