diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md
index b84f2a3c0..9be270999 100644
--- a/docs/release-notes/version-3.0.md
+++ b/docs/release-notes/version-3.0.md
@@ -5,6 +5,7 @@
### Enhancements
* [#7751](https://github.com/netbox-community/netbox/issues/7751) - Get API user from LDAP only when `FIND_GROUP_PERMS` is enabled
+* [#7823](https://github.com/netbox-community/netbox/issues/7823) - Fix issue where `return_url` is not honored when 'Save & Continue' button is present
* [#7885](https://github.com/netbox-community/netbox/issues/7885) - Linkify VLAN name in VLANs table
* [#7892](https://github.com/netbox-community/netbox/issues/7892) - Add L22-30 power port & outlet types
* [#7932](https://github.com/netbox-community/netbox/issues/7932) - Improve performance of the "quick find" function
diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js
index b8567f060..c4a8e802d 100644
Binary files a/netbox/project-static/dist/netbox.js and b/netbox/project-static/dist/netbox.js differ
diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map
index c2e1c5b4f..b95e6ba02 100644
Binary files a/netbox/project-static/dist/netbox.js.map and b/netbox/project-static/dist/netbox.js.map differ
diff --git a/netbox/project-static/src/forms/elements.ts b/netbox/project-static/src/forms/elements.ts
index 978c25e10..5cb17f5c7 100644
--- a/netbox/project-static/src/forms/elements.ts
+++ b/netbox/project-static/src/forms/elements.ts
@@ -1,4 +1,32 @@
-import { getElements, scrollTo } from '../util';
+import { getElements, scrollTo, isTruthy } from '../util';
+
+/**
+ * When editing an object, it is sometimes desirable to customize the form action *without*
+ * overriding the form's `submit` event. For example, the 'Save & Continue' button. We don't want
+ * to use the `formaction` attribute on that element because it will be included on the form even
+ * if the button isn't clicked.
+ *
+ * @example
+ * ```html
+ *
+ * ```
+ *
+ * @param event Click event.
+ */
+function handleSubmitWithReturnUrl(event: MouseEvent): void {
+ const element = event.target as HTMLElement;
+ if (element.tagName === 'BUTTON') {
+ const button = element as HTMLButtonElement;
+ const action = button.getAttribute('return-url');
+ const form = button.form;
+ if (form !== null && isTruthy(action)) {
+ form.action = action;
+ form.submit();
+ }
+ }
+}
function handleFormSubmit(event: Event, form: HTMLFormElement): void {
// Track the names of each invalid field.
@@ -38,6 +66,15 @@ function handleFormSubmit(event: Event, form: HTMLFormElement): void {
}
}
+/**
+ * Attach event listeners to form buttons with the `return-url` attribute present.
+ */
+function initReturnUrlSubmitButtons(): void {
+ for (const button of getElements('button[return-url]')) {
+ button.addEventListener('click', handleSubmitWithReturnUrl);
+ }
+}
+
/**
* Attach an event listener to each form's submitter (button[type=submit]). When called, the
* callback checks the validity of each form field and adds the appropriate Bootstrap CSS class
@@ -54,4 +91,5 @@ export function initFormElements(): void {
submitter.addEventListener('click', (event: Event) => handleFormSubmit(event, form));
}
}
+ initReturnUrlSubmitButtons();
}
diff --git a/netbox/templates/dcim/interface_edit.html b/netbox/templates/dcim/interface_edit.html
index 38b22fe5e..317b49a79 100644
--- a/netbox/templates/dcim/interface_edit.html
+++ b/netbox/templates/dcim/interface_edit.html
@@ -51,7 +51,7 @@
{% block buttons %}
Cancel
{% if obj.pk %}
-
+
{% else %}
diff --git a/netbox/templates/virtualization/vminterface_edit.html b/netbox/templates/virtualization/vminterface_edit.html
index b4d097513..7e5b8599c 100644
--- a/netbox/templates/virtualization/vminterface_edit.html
+++ b/netbox/templates/virtualization/vminterface_edit.html
@@ -46,7 +46,7 @@
{% block buttons %}
Cancel
{% if obj.pk %}
-
+
{% else %}