diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py
index d3ea3acd7..320e52680 100644
--- a/netbox/dcim/views.py
+++ b/netbox/dcim/views.py
@@ -3183,7 +3183,7 @@ class CableView(generic.ObjectView):
class CableEditView(generic.ObjectEditView):
queryset = Cable.objects.all()
template_name = 'dcim/cable_edit.html'
- htmx_template_name = 'dcim/cable_edit.html'
+ htmx_template_name = 'dcim/htmx/cable_edit.html'
def dispatch(self, request, *args, **kwargs):
@@ -3214,8 +3214,6 @@ class CableEditView(generic.ObjectEditView):
CABLE_TERMINATION_TYPES.get(b_terminations_type)
)
- self.skip_htmx = True
-
self.form = forms.get_cable_form(a_type, b_type)
return super().alter_object(obj, request, url_args, url_kwargs)
diff --git a/netbox/netbox/views/generic/object_views.py b/netbox/netbox/views/generic/object_views.py
index e352f5f2a..21d740b8e 100644
--- a/netbox/netbox/views/generic/object_views.py
+++ b/netbox/netbox/views/generic/object_views.py
@@ -167,7 +167,7 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
"""
template_name = 'generic/object_edit.html'
form = None
- skip_htmx = False
+ htmx_template_name = 'htmx/form.html'
def dispatch(self, request, *args, **kwargs):
# Determine required permission based on whether we are editing an existing object
@@ -228,8 +228,8 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
restrict_form_fields(form, request.user)
# If this is an HTMX request, return only the rendered form HTML
- if is_htmx(request) and not self.skip_htmx:
- return render(request, 'htmx/form.html', {
+ if is_htmx(request):
+ return render(request, self.htmx_template_name, {
'form': form,
})
diff --git a/netbox/templates/dcim/cable_edit.html b/netbox/templates/dcim/cable_edit.html
index c27ca2992..fbe877d87 100644
--- a/netbox/templates/dcim/cable_edit.html
+++ b/netbox/templates/dcim/cable_edit.html
@@ -1,113 +1,5 @@
{% extends 'generic/object_edit.html' %}
-{% load static %}
-{% load helpers %}
-{% load form_helpers %}
-{% load i18n %}
{% block form %}
- {# A side termination #}
-
-
-
{% trans "A Side" %}
-
- {% if 'termination_a_device' in form.fields %}
- {% render_field form.termination_a_device %}
- {% endif %}
- {% if 'termination_a_powerpanel' in form.fields %}
- {% render_field form.termination_a_powerpanel %}
- {% endif %}
- {% if 'termination_a_circuit' in form.fields %}
- {% render_field form.termination_a_circuit %}
- {% endif %}
- {% if 'a_terminations' in form.fields %}
- {% render_field form.a_terminations %}
- {% else %}
-
-
-
-
-
-
-
-
-
- {% endif %}
-
-
- {# B side termination #}
-
-
-
{% trans "B Side" %}
-
- {% if 'termination_b_device' in form.fields %}
- {% render_field form.termination_b_device %}
- {% endif %}
- {% if 'termination_b_powerpanel' in form.fields %}
- {% render_field form.termination_b_powerpanel %}
- {% endif %}
- {% if 'termination_b_circuit' in form.fields %}
- {% render_field form.termination_b_circuit %}
- {% endif %}
- {% if 'b_terminations' in form.fields %}
- {% render_field form.b_terminations %}
- {% else %}
-
-
-
-
-
-
-
-
-
- {% endif %}
-
-
- {# Cable attributes #}
-
-
-
{% trans "Cable" %}
-
- {% render_field form.status %}
- {% render_field form.type %}
- {% render_field form.label %}
- {% render_field form.description %}
- {% render_field form.color %}
-
-
-
- {{ form.length }}
-
-
- {{ form.length_unit }}
-
-
-
- {% render_field form.tags %}
-
-
-
-
-
{% trans "Tenancy" %}
-
- {% render_field form.tenant_group %}
- {% render_field form.tenant %}
-
-
- {% if form.custom_fields %}
-
-
-
{% trans "Custom Fields" %}
-
- {% render_custom_fields form %}
-
- {% endif %}
-
- {% if form.comments %}
-
-
{% trans "Comments" %}
- {% render_field form.comments %}
-
- {% endif %}
-
+ {% include 'dcim/htmx/cable_edit.html' %}
{% endblock %}
diff --git a/netbox/templates/dcim/htmx/cable_edit.html b/netbox/templates/dcim/htmx/cable_edit.html
new file mode 100644
index 000000000..6fcbd71e4
--- /dev/null
+++ b/netbox/templates/dcim/htmx/cable_edit.html
@@ -0,0 +1,116 @@
+{% load static %}
+{% load helpers %}
+{% load form_helpers %}
+{% load i18n %}
+
+
+{# A side termination #}
+
+
+
{% trans "A Side" %}
+
+ {% if 'termination_a_device' in form.fields %}
+ {% render_field form.termination_a_device %}
+ {% endif %}
+ {% if 'termination_a_powerpanel' in form.fields %}
+ {% render_field form.termination_a_powerpanel %}
+ {% endif %}
+ {% if 'termination_a_circuit' in form.fields %}
+ {% render_field form.termination_a_circuit %}
+ {% endif %}
+ {% if 'a_terminations' in form.fields %}
+ {% render_field form.a_terminations %}
+ {% else %}
+
+
+
+
+
+
+ {% endif %}
+
+
+{# B side termination #}
+
+
+
{% trans "B Side" %}
+
+ {% if 'termination_b_device' in form.fields %}
+ {% render_field form.termination_b_device %}
+ {% endif %}
+ {% if 'termination_b_powerpanel' in form.fields %}
+ {% render_field form.termination_b_powerpanel %}
+ {% endif %}
+ {% if 'termination_b_circuit' in form.fields %}
+ {% render_field form.termination_b_circuit %}
+ {% endif %}
+ {% if 'b_terminations' in form.fields %}
+ {% render_field form.b_terminations %}
+ {% else %}
+
+
+
+
+
+
+ {% endif %}
+
+
+{# Cable attributes #}
+
+
+
{% trans "Cable" %}
+
+ {% render_field form.status %}
+ {% render_field form.type %}
+ {% render_field form.label %}
+ {% render_field form.description %}
+ {% render_field form.color %}
+
+
+
+ {{ form.length }}
+
+
+ {{ form.length_unit }}
+
+
+
+ {% render_field form.tags %}
+
+
+
+
+
{% trans "Tenancy" %}
+
+ {% render_field form.tenant_group %}
+ {% render_field form.tenant %}
+
+
+{% if form.custom_fields %}
+
+
+
{% trans "Custom Fields" %}
+
+ {% render_custom_fields form %}
+
+{% endif %}
+
+{% if form.comments %}
+
+
{% trans "Comments" %}
+ {% render_field form.comments %}
+
+{% endif %}
\ No newline at end of file