Form rendering improvements

This commit is contained in:
Tobias Kunze 2025-03-20 09:11:15 +01:00
parent f17e1a0782
commit 6ed19e90a3
4 changed files with 17 additions and 10 deletions

View file

@ -1,5 +1,10 @@
{% load i18n %}
<div class="form-group d-inline{% if field.field.required %} mandatory{% endif %}{% if errors %} is-invalid{% endif %}{% if extra_class %} {{ extra_class }}{% endif %}">
<div class="form-group{% if field.field.required %} mandatory{% endif %}{% if errors %} is-invalid{% endif %}{% if extra_class %} {{ extra_class }}{% endif %}">
{% if not hide_label %}
{% if field.field.widget.input_type != "checkbox" or field.field.widget.allow_multiple_selected %}
<label for="{{ field.auto_id }}" class="form-label">{{ field.label }}</label>
{% endif %}
{% endif %}
{% if field.use_fieldset %}
<fieldset {% if field.help_text and field.auto_id and "aria-describedby" not in field.field.widget.attrs %} aria-describedby="{{ field.auto_id }}_helptext"{% endif %}>
{% endif %}

View file

@ -1 +1 @@
{% include "frontend/forms/field.html" with extra_class="d-inline" %}
{% include "frontend/forms/field.html" with extra_class="d-inline" hide_label=True %}

View file

@ -22,7 +22,7 @@
{% endpartialdef user-email %}
{% partialdef user-company %}
<td>
{{ request.user.company|default_if_none:"" }}
{{ request.user.company|default:"" }}
<button class="btn btn-primary"
hx-get="{% url 'frontend:profile' %}?fragment=user-company-edit"
hx-target="closest td"

View file

@ -5,11 +5,13 @@
{% include "includes/form_errors.html" %}
{% csrf_token %}
{{ form }}
<button class="btn btn-primary" type="submit">
{% if form_submit_label %}
{{ form_submit_label }}
{% else %}
{% translate "Save" %}
{% endif %}
</button>
<div class="col-sm-12 d-flex justify-content-end">
<button class="btn btn-primary me-1 mb-1" type="submit">
{% if form_submit_label %}
{{ form_submit_label }}
{% else %}
{% translate "Save" %}
{% endif %}
</button>
</div>
</form>