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

@@ -1,25 +1,18 @@
{% extends "base.html" %}
{% from "macros.html" import render_field %}
{% block title %}Update User{% endblock %}
{% block content_title %}Update User{% endblock %}
{% block content_description %}Update given user account{% endblock %}
{% block content %}
<form method="post">
{{ form.hidden_tag() }}
{% for field in form %}
<div class="form-group">
{{ field.label }}
{{ field(class="form-control", disabled=true) if field.name in ['email', 'user_name'] else field(class="form-control") }}
{% if field.errors %}
<div class="alert alert-danger">
{% for error in field.errors %}
<p>{{ error }}</p>
{% endfor %}
</div>
{% endif %}
</div>
{% endfor %}
<button type="submit" class="btn btn-primary">Update User</button>
</form>
<form method="post">
{{ form.hidden_tag() }}
{% set disabled_fields = ['email', 'user_name'] %}
{% set exclude_fields = ['password', 'confirm_password'] %}
{% for field in form %}
{{ render_field(field, disabled_fields, exclude_fields) }}
{% endfor %}
<button type="submit" class="btn btn-primary">Update User</button>
</form>
{% endblock %}