#7450: Clean up object edit forms

This commit is contained in:
jeremystretch
2021-10-05 15:37:49 -04:00
parent dd79aae137
commit 9089f5cf67
14 changed files with 129 additions and 170 deletions

View File

@@ -6,18 +6,6 @@
{% if obj.pk %}Editing {{ obj_type }} {{ obj }}{% else %}Add a new {{ obj_type }}{% endif %}
{% endblock title %}
{% block controls %}
{% if obj and settings.DOCS_ROOT %}
<div class="controls">
<div class="control-group">
<a href="{{ obj|get_docs_url }}" target="_blank" class="btn btn-sm btn-outline-secondary" title="View model documentation">
<i class="mdi mdi-help-circle"></i> Help
</a>
</div>
</div>
{% endif %}
{% endblock controls %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
<li class="nav-item" role="presentation">
@@ -31,6 +19,16 @@
{% block content-wrapper %}
<div class="tab-content">
<div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="object-list-tab">
{# Link to model documentation #}
{% if obj and settings.DOCS_ROOT %}
<div class="float-end">
<a href="{{ obj|get_docs_url }}" target="_blank" class="btn btn-sm btn-outline-secondary" title="View model documentation">
<i class="mdi mdi-help-circle"></i> Help
</a>
</div>
{% endif %}
<form action="" method="post" enctype="multipart/form-data" class="form-object-edit">
{% csrf_token %}
{% for field in form.hidden_fields %}
@@ -42,7 +40,7 @@
{# Render grouped fields according to Form #}
{% for group, fields in form.Meta.fieldsets %}
<div class="field-group my-4">
<div class="field-group my-5">
<div class="row mb-2">
<h5 class="offset-sm-3">{{ group }}</h5>
</div>
@@ -50,14 +48,10 @@
{% render_field form|getfield:name %}
{% endfor %}
</div>
{% if not forloop.last %}
<hr />
{% endif %}
{% endfor %}
{% if form.custom_fields %}
<hr />
<div class="field-group my-4">
<div class="field-group my-5">
<div class="row mb-2">
<h5 class="offset-sm-3">Custom Fields</h5>
</div>
@@ -66,15 +60,15 @@
{% endif %}
{% if form.comments %}
<hr />
<div class="field-group my-4">
{% render_field form.comments label='Comments' %}
<div class="field-group my-5">
<h5 class="text-center">Comments</h5>
{% render_field form.comments %}
</div>
{% endif %}
{% else %}
{# Render all fields in a single group #}
<div class="field-group my-4">
<div class="field-group my-5">
{% block form_fields %}{% render_form form %}{% endblock %}
</div>
{% endif %}