-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Environment
- Python version: Example: 3.6.9
- NetBox version: Example: 2.8.5
Proposed Functionality
This is a continuation of #3766, which asked about being able to filter form fields based on the input of other form fields.
One point that was not addressed as this comment. From what I could find, it is not possible to dynamically adjust the query used for a field based on what value is selected in another field.
I found that APISelect
widget has a parameter called conditional_query_params
, which seems to come pretty close, but as far as I can see you cannot use that to adjust the actual query values, only add static conditions based on another condition.
So it would be nice if we could refer to the selected value from another field, and use that value in the query params.
Something like
site = ObjectVar(
description = "Site",
queryset = Site.objects.all()
)
prefix = ObjectVar(
queryset = Prefix.objects.all(),
widget = APISelect(
api_url="/api/ipam/prefixes/",
dynamic_query_params={
'site': 'site_id={{id}}'
},
display_field='prefix'
)
)
Use Case
Same as #3766
For example: Have a form where you first select a site, and then select a prefix within that site.
Database Changes
None
External Dependencies
None