[PR #20550] [MERGED] Fixes #20542: Add form prefix to POST handler in ObjectEditView #15962

Closed
opened 2025-12-30 00:25:02 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20550
Author: @jnovinger
Created: 10/9/2025
Status: Merged
Merged: 10/9/2025
Merged by: @arthanson

Base: mainHead: 20542-quick-add-forms-broken


📝 Commits (1)

  • c517b44 Fixes #20542: Add form prefix to POST handler in ObjectEditView

📊 Changes

2 files changed (+30 additions, -2 deletions)

View changed files

📝 netbox/dcim/tests/test_views.py (+28 -1)
📝 netbox/netbox/views/generic/object_views.py (+2 -1)

📄 Description

Fixes: #20542

Commit d22246688 added form prefix support to the GET handler to fix Markdown preview functionality in quick add modals. The form prefix allows Django to properly namespace field names and IDs when rendering forms within the quick add modal context.

However, the corresponding change was not made to the POST handler. This created a mismatch where form fields were rendered with the quickadd- prefix during GET requests, but the POST handler instantiated forms without the prefix. When users submitted quick add forms, Django looked for unprefixed field names like address and status in the POST data, but the actual submitted data used prefixed names like quickadd-address and quickadd-status. This caused validation to fail immediately with "This field is required" errors for all required fields, making every quick add form unusable.

The fix adds the same prefix detection logic to the POST handler that was added to the GET handler, checking for the _quickadd parameter in the query string and applying the quickadd prefix when present. This ensures consistent form field naming between rendering and validation.

A regression test has been added to MACAddressTestCase to verify that MAC addresses can be successfully created via the quick add modal, preventing this issue from recurring. This test should be promoted to a template test whenever it becomes possible to determine if a model should support quick-add functionality.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20550 **Author:** [@jnovinger](https://github.com/jnovinger) **Created:** 10/9/2025 **Status:** ✅ Merged **Merged:** 10/9/2025 **Merged by:** [@arthanson](https://github.com/arthanson) **Base:** `main` ← **Head:** `20542-quick-add-forms-broken` --- ### 📝 Commits (1) - [`c517b44`](https://github.com/netbox-community/netbox/commit/c517b445847667c9b85eafd658a19b8199c3ae4c) Fixes #20542: Add form prefix to `POST` handler in `ObjectEditView` ### 📊 Changes **2 files changed** (+30 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/tests/test_views.py` (+28 -1) 📝 `netbox/netbox/views/generic/object_views.py` (+2 -1) </details> ### 📄 Description Fixes: #20542 Commit d22246688 added form prefix support to the `GET` handler to fix Markdown preview functionality in quick add modals. The form prefix allows Django to properly namespace field names and IDs when rendering forms within the quick add modal context. However, the corresponding change was not made to the `POST` handler. This created a mismatch where form fields were rendered with the `quickadd-` prefix during `GET` requests, but the `POST` handler instantiated forms without the prefix. When users submitted quick add forms, Django looked for unprefixed field names like `address` and `status` in the `POST` data, but the actual submitted data used prefixed names like `quickadd-address` and `quickadd-status`. This caused validation to fail immediately with "This field is required" errors for all required fields, making every quick add form unusable. The fix adds the same prefix detection logic to the `POST` handler that was added to the `GET` handler, checking for the `_quickadd` parameter in the query string and applying the `quickadd` prefix when present. This ensures consistent form field naming between rendering and validation. A regression test has been added to `MACAddressTestCase` to verify that MAC addresses can be successfully created via the quick add modal, preventing this issue from recurring. This test should be promoted to a template test whenever it becomes possible to determine if a model should support quick-add functionality. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:25:02 +01:00
adam closed this issue 2025-12-30 00:25:02 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15962