Skip to content

Commit

Permalink
fix: stacked inline label and field alignment in django 4.2+ (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino authored Jul 14, 2024
1 parent 68353ae commit c0bf70b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions nested_admin/templates/nesting/admin/includes/inline.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{% load nested_admin %}
<fieldset class="module aligned djn-module {{ fieldset.classes }}{% if inline_admin_form.form.inlines %} has-inlines{% endif %}">
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
{% if fieldset.description %}
<div class="description">{{ fieldset.description|safe }}</div>
{% endif %}
{% for line in fieldset %}
<div class="form-row{% if line.fields|length == 1 and line.errors %} errors{% endif %}{% if not line.has_visible_field %} hidden{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}{% if forloop.last and forloop.parentloop.last %} djn-form-row-last{% endif %}">
{% if line.fields|length == 1 %}{{ line.errors }}{% endif %}
{% if line.fields|length == 1 %}{{ line.errors }}{% elif "4.2"|django_version_gte %}<div class="flex-container form-multiline">{% endif %}
{% for field in line %}
<div class="{% if line.fields|length == 1 and field.is_checkbox %}checkbox-row{% else %}{% if not line.fields|length == 1 %}fieldBox{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %} {% endif %}field-{{ field.field.name }}{% endif %}">
{% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}
{% if "4.2"|django_version_gte %}
<div>
{% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}
{% endif %}
<div class="{% if "4.2"|django_version_gte %}flex-container {% endif %}{% if line.fields|length == 1 and field.is_checkbox %}checkbox-row{% else %}{% if not line.fields|length == 1 %}fieldBox{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %} {% endif %}field-{{ field.field.name }}{% endif %}">
{% if "4.2"|django_version_lt %}{% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}{% endif %}
{% if field.is_checkbox %}
{{ field.field }}{{ field.label_tag }}
{% else %}
Expand All @@ -19,13 +24,15 @@
{{ field.field }}
{% endif %}
{% endif %}
{% if field.field.help_text %}
<div class="help"{% if field.field.id_for_label %} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
{{ field.field.help_text|safe }}
</div>
{% endif %}
</div>
{% if field.field.help_text %}
<div class="help"{% if field.field.id_for_label %} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
{{ field.field.help_text|safe }}
</div>
{% endif %}
{% if "4.2"|django_version_gte %}</div>{% endif %}
{% endfor %}
{% if "4.2"|django_version_gte %}{% if not line.fields|length == 1 %}</div>{% endif %}{% endif %}
</div>
{% endfor %}
</fieldset>

0 comments on commit c0bf70b

Please sign in to comment.