object_edit.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {% extends 'base/layout.html' %}
  2. {% load i18n %}
  3. {% comment %}
  4. Blocks:
  5. form: Content within the <form> element
  6. buttons: Form submission buttons
  7. Context:
  8. object: Python instance of the object being edited
  9. form: The edit form
  10. return_url: The URL to which the user is redirected after submitting the form
  11. {% endcomment %}
  12. {% block title %}
  13. {% if object.pk %}
  14. {% trans "Editing" %} {{ object|meta:"verbose_name" }} {{ object }}
  15. {% else %}
  16. {% blocktrans with object_type=object|meta:"verbose_name" %}
  17. Add a new {{ object_type }}
  18. {% endblocktrans %}
  19. {% endif %}
  20. {% endblock title %}
  21. {% block tabs %}
  22. <ul class="nav nav-tabs px-3">
  23. <li class="nav-item" role="presentation">
  24. <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">
  25. {% if object.pk %}{% trans "Edit" %}{% else %}{% trans "Create" %}{% endif %}
  26. </button>
  27. </li>
  28. </ul>
  29. {% endblock tabs %}
  30. {% block content-wrapper %}
  31. <div class="tab-content">
  32. <div class="tab-pane show active" id="edit-form" role="tabpanel" aria-labelledby="object-list-tab">
  33. {# Warn about missing prerequisite objects #}
  34. {% if prerequisite_model %}
  35. {% include 'inc/missing_prerequisites.html' %}
  36. {% endif %}
  37. {# Link to model documentation #}
  38. {% if settings.DOCS_ROOT and object.docs_url %}
  39. <div class="float-end">
  40. <a href="{{ object.docs_url }}" target="_blank" class="btn btn-sm btn-outline-secondary" title="{% trans "View model documentation" %}">
  41. <i class="mdi mdi-help-circle"></i> {% trans "Help" %}
  42. </a>
  43. </div>
  44. {% endif %}
  45. <form action="" method="post" enctype="multipart/form-data" class="form-object-edit mt-5">
  46. {% csrf_token %}
  47. <div id="form_fields">
  48. {% block form %}
  49. {% include 'htmx/form.html' %}
  50. {% endblock form %}
  51. </div>
  52. <div class="text-end my-3">
  53. {% block buttons %}
  54. {% if object.pk %}
  55. <button type="submit" name="_update" class="btn btn-primary">
  56. {% trans "Save" %}
  57. </button>
  58. {% else %}
  59. <button type="submit" name="_create" class="btn btn-primary">
  60. {% trans "Create" %}
  61. </button>
  62. <button type="submit" name="_addanother" class="btn btn-outline-primary">
  63. {% trans "Create & Add Another" %}
  64. </button>
  65. {% endif %}
  66. <a class="btn btn-outline-danger" href="{{ return_url }}">{% trans "Cancel" %}</a>
  67. {% endblock buttons %}
  68. </div>
  69. </form>
  70. </div>
  71. </div>
  72. {% endblock content-wrapper %}
  73. {% block modals %}
  74. {% include 'inc/htmx_modal.html' with size='lg' %}
  75. {% endblock %}