1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

117 lines
3.8 KiB
HTML
Raw Normal View History

{% extends 'base/layout.html' %}
{% load form_helpers %}
{% load helpers %}
{% comment %}
Blocks:
form: Content within the <form> element
buttons: Form submission buttons
Context:
object: Python instance of the object being edited
form: The edit form
return_url: The URL to which the user is redirected after submitting the form
{% endcomment %}
2021-05-23 13:21:52 -07:00
{% block title %}
{% if object.pk %}Editing {{ object|meta:"verbose_name" }} {{ object }}{% else %}Add a new {{ object|meta:"verbose_name" }}{% endif %}
2021-05-23 13:21:52 -07:00
{% endblock title %}
2021-08-06 16:11:02 -04:00
{% block tabs %}
<ul class="nav nav-tabs px-3">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="edit-form-tab" data-bs-toggle="tab" data-bs-target="#edit-form" type="button" role="tab" aria-controls="edit-form" aria-selected="true">
{% if object.pk %}Edit{% else %}Create{% endif %}
2021-08-06 16:11:02 -04:00
</button>
</li>
</ul>
{% endblock tabs %}
{% block content-wrapper %}
<div class="tab-content">
<div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="object-list-tab">
2021-10-05 15:37:49 -04:00
{# Link to model documentation #}
{% if object and settings.DOCS_ROOT %}
2021-10-05 15:37:49 -04:00
<div class="float-end">
<a href="{{ object|get_docs_url }}" target="_blank" class="btn btn-sm btn-outline-secondary" title="View model documentation">
2021-10-05 15:37:49 -04:00
<i class="mdi mdi-help-circle"></i> Help
</a>
</div>
{% endif %}
2021-12-28 10:22:00 -05:00
<form action="" method="post" enctype="multipart/form-data" class="form-object-edit mt-5">
2021-08-06 16:11:02 -04:00
{% csrf_token %}
2021-08-13 13:35:23 -04:00
{% block form %}
{% if form.fieldsets %}
2021-08-13 13:35:23 -04:00
2021-12-28 09:53:56 -05:00
{# Render hidden fields #}
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
2021-08-13 13:35:23 -04:00
{# Render grouped fields according to Form #}
{% for group, fields in form.fieldsets %}
2021-12-28 08:54:03 -05:00
<div class="field-group mb-5">
2021-08-24 13:59:54 -04:00
<div class="row mb-2">
<h5 class="offset-sm-3">{{ group }}</h5>
</div>
2021-08-13 13:35:23 -04:00
{% for name in fields %}
2021-12-28 10:22:00 -05:00
{% with field=form|getfield:name %}
{% if not field.field.widget.is_hidden %}
{% render_field field %}
{% endif %}
{% endwith %}
2021-07-20 13:21:09 -04:00
{% endfor %}
2021-08-13 13:35:23 -04:00
</div>
{% endfor %}
{% if form.custom_fields %}
2021-12-28 08:54:03 -05:00
<div class="field-group mb-5">
2021-08-25 15:03:19 -04:00
<div class="row mb-2">
2021-08-24 13:59:54 -04:00
<h5 class="offset-sm-3">Custom Fields</h5>
</div>
2021-08-13 13:35:23 -04:00
{% render_custom_fields form %}
</div>
{% endif %}
{% if form.comments %}
2021-12-28 08:54:03 -05:00
<div class="field-group mb-5">
2021-10-05 15:37:49 -04:00
<h5 class="text-center">Comments</h5>
{% render_field form.comments %}
2021-08-13 13:35:23 -04:00
</div>
{% endif %}
{% else %}
{# Render all fields in a single group #}
2021-12-28 08:54:03 -05:00
<div class="field-group mb-5">
{% render_form form %}
2021-08-13 13:35:23 -04:00
</div>
{% endif %}
{% endblock form %}
<div class="text-end my-3">
{% block buttons %}
<a class="btn btn-outline-danger" href="{{ return_url }}">Cancel</a>
{% if object.pk %}
2021-08-13 13:35:23 -04:00
<button type="submit" name="_update" class="btn btn-primary">
Save
</button>
{% else %}
<button type="submit" name="_addanother" class="btn btn-outline-primary">
Create & Add Another
</button>
<button type="submit" name="_create" class="btn btn-primary">
Create
</button>
{% endif %}
{% endblock buttons %}
2021-08-06 16:11:02 -04:00
</div>
</form>
</div>
2021-08-06 16:11:02 -04:00
</div>
2021-08-06 16:11:02 -04:00
{% endblock content-wrapper %}