[PR #9435] [MERGED] Fixes #9430 - Make sure initial data is passed as array for DynamicModelChoiceFields #13467

Closed
opened 2025-12-29 23:19:01 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/9435
Author: @kkthxbye-code
Created: 5/27/2022
Status: Merged
Merged: 5/31/2022
Merged by: @jeremystretch

Base: developHead: fix-9430


📝 Commits (1)

  • 6d3cded Make sure initial data is passed as array for DynamicModelChoiceFields

📊 Changes

1 file changed (+5 additions, -0 deletions)

View changed files

📝 netbox/utilities/forms/fields/dynamic.py (+5 -0)

📄 Description

Fixes: #9430

When pre-filling a MultiObjectVar for custom script execution passing a single pk above 9 would not work. Passing multiple values like: ?devices=1&device=99 works.

The error occurs in line 95 here:

2e5a5f71ba/netbox/utilities/forms/fields/dynamic.py (L88-L100)

When passed a two or more digit number in a string, the value seems to get split into a string, so instead of looking up pk 123, it looks up pk 1, 2 and 3.

I'm not sure exactly what's going on here so there might be a better place to fix the issue, please let me know and I'll change it.


🔄 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/9435 **Author:** [@kkthxbye-code](https://github.com/kkthxbye-code) **Created:** 5/27/2022 **Status:** ✅ Merged **Merged:** 5/31/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `fix-9430` --- ### 📝 Commits (1) - [`6d3cded`](https://github.com/netbox-community/netbox/commit/6d3cded57934327f3d4167069be41fde860ee7dd) Make sure initial data is passed as array for DynamicModelChoiceFields ### 📊 Changes **1 file changed** (+5 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `netbox/utilities/forms/fields/dynamic.py` (+5 -0) </details> ### 📄 Description ### Fixes: #9430 When pre-filling a MultiObjectVar for custom script execution passing a single pk above 9 would not work. Passing multiple values like: `?devices=1&device=99` works. The error occurs in line 95 here: https://github.com/netbox-community/netbox/blob/2e5a5f71ba4622b2989d892d4215e2aefe59b91c/netbox/utilities/forms/fields/dynamic.py#L88-L100 When passed a two or more digit number in a string, the value seems to get split into a string, so instead of looking up pk 123, it looks up pk 1, 2 and 3. I'm not sure exactly what's going on here so there might be a better place to fix the issue, please let me know and I'll change it. --- <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-29 23:19:01 +01:00
adam closed this issue 2025-12-29 23:19:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13467