Object Selector View pre-selected filter choices #11290

Closed
opened 2025-12-29 21:43:06 +01:00 by adam · 9 comments
Owner

Originally created by @PaulLocksley on GitHub (Jun 18, 2025).

NetBox version

v4.3.2

Feature type

Change to existing functionality

Proposed functionality

I would like the Object Selector View to have configurable default search fields.

I believe this can be done via allowing admins to extend the selector_fields attributes in filterset_forms, similar to how admins can extend table default views.

This may be configured via a new setting such as DEFAULT_OBJECT_SELECTION_FIELDS
and look something like

DEFAULT_OBJECT_SELECTION_FIELDS = {
    'dcim.Site': [
        'filter_id'. 'q', 'region_id', 'group_id', 'cf_custom_field_name'
    ]
}

Resulting in the effective selection value:

class SiteFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFilterSetForm):
    model = Site
    ...
    selector_fields = ('filter_id', 'q', 'region_id', 'group_id','cf_custom_field_name')

and the ui presented to the user:

Image

Use case

My team has a custom field we use when selecting sites often, this would smooth out the workflow and let as add the 'cf_custom_field' selector as a default option improving user experience.

Database changes

None

External dependencies

None

Originally created by @PaulLocksley on GitHub (Jun 18, 2025). ### NetBox version v4.3.2 ### Feature type Change to existing functionality ### Proposed functionality I would like the Object Selector View to have configurable default search fields. I believe this can be done via allowing admins to extend the selector_fields attributes in filterset_forms, similar to how admins can extend table default views. This may be configured via a new setting such as DEFAULT_OBJECT_SELECTION_FIELDS and look something like ``` DEFAULT_OBJECT_SELECTION_FIELDS = { 'dcim.Site': [ 'filter_id'. 'q', 'region_id', 'group_id', 'cf_custom_field_name' ] } ``` Resulting in the effective selection value: ``` class SiteFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFilterSetForm): model = Site ... selector_fields = ('filter_id', 'q', 'region_id', 'group_id','cf_custom_field_name') ``` and the ui presented to the user: ![Image](https://github.com/user-attachments/assets/cec2e382-f59d-4ad0-9487-671fc4a1fad4) ### Use case My team has a custom field we use when selecting sites often, this would smooth out the workflow and let as add the 'cf_custom_field' selector as a default option improving user experience. ### Database changes None ### External dependencies None
adam added the type: featurestatus: under review labels 2025-12-29 21:43:06 +01:00
adam closed this issue 2025-12-29 21:43:06 +01:00
Author
Owner

@PaulLocksley commented on GitHub (Jun 18, 2025):

I'm happy to do the work here if this is wanted and appropriate, I've already spent some time on an implementation but it is naive (See commit here ).

If I've missed something please let me know :)

@PaulLocksley commented on GitHub (Jun 18, 2025): I'm happy to do the work here if this is wanted and appropriate, I've already spent some time on an implementation but it is naive (See commit [here](https://github.com/netbox-community/netbox/commit/1f62a7a0556a05cca609b977f4a560ce6f16e3b0) ). If I've missed something please let me know :)
Author
Owner

@arthanson commented on GitHub (Jun 18, 2025):

@PaulLocksley what are you specifically referencing when you say "Object Selector View" is it the filter form for list views? Can you please specify what page you are looking to see these on, not very clear from your description.

@arthanson commented on GitHub (Jun 18, 2025): @PaulLocksley what are you specifically referencing when you say "Object Selector View" is it the filter form for list views? Can you please specify what page you are looking to see these on, not very clear from your description.
Author
Owner

@PaulLocksley commented on GitHub (Jun 19, 2025):

Hi @arthanson,
The ObjectSelectorView located here, it's rendered when you select the little button to the side of a DynamicModelChoiceField with selector set to true.

For example the screenshot in the issue above comes from the circuit termination form:

Image

@PaulLocksley commented on GitHub (Jun 19, 2025): Hi @arthanson, The ObjectSelectorView located [here](https://github.com/netbox-community/netbox/blob/main/netbox/netbox/views/htmx.py), it's rendered when you select the little button to the side of a DynamicModelChoiceField with selector set to true. For example the screenshot in the issue above comes from the circuit termination form: ![Image](https://github.com/user-attachments/assets/c4533482-7a70-48ea-b5a8-891d0cf3a3fd)
Author
Owner

@github-actions[bot] commented on GitHub (Jun 26, 2025):

This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.

@github-actions[bot] commented on GitHub (Jun 26, 2025): This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.
Author
Owner

@PaulLocksley commented on GitHub (Jun 27, 2025):

Hey @arthanson, were there any other details wanted here?
Ideally the github actions bot doesn't close this out 😄

@PaulLocksley commented on GitHub (Jun 27, 2025): Hey @arthanson, were there any other details wanted here? Ideally the github actions bot doesn't close this out 😄
Author
Owner

@jeremystretch commented on GitHub (Jul 10, 2025):

My team has a custom field we use when selecting sites often, this would smooth out the workflow and let as add the 'cf_custom_field' selector as a default option improving user experience.

Filterable custom fields are included in the list of available filter along the lefthand side of the selector dialog, but are not enabled by default.

You don't specify how the proposed configuration would be achieved, but IMO devising a mechanism to allow specifying arbitrary fields is not going to be worth the development required, given that the only limitation that exists today is clicking on the filter in the list.

@jeremystretch commented on GitHub (Jul 10, 2025): > My team has a custom field we use when selecting sites often, this would smooth out the workflow and let as add the 'cf_custom_field' selector as a default option improving user experience. Filterable custom fields are included in the list of available filter along the lefthand side of the selector dialog, but are not enabled by default. You don't specify how the proposed configuration would be achieved, but IMO devising a mechanism to allow specifying arbitrary fields is not going to be worth the development required, given that the only limitation that exists today is clicking on the filter in the list.
Author
Owner

@PaulLocksley commented on GitHub (Jul 11, 2025):

Hey @jeremystretch , yeah they are available, that was never in question, it's just a pain point for our users.

You don't specify how the proposed configuration would be achieved

I did specify the configuration, please see the section in the issue body:

This may be configured via a new setting such as DEFAULT_OBJECT_SELECTION_FIELDS
and look something like

DEFAULT_OBJECT_SELECTION_FIELDS = {
'dcim.Site': [
'filter_id'. 'q', 'region_id', 'group_id', 'cf_custom_field_name'
]
}

And the further comment above containing a branch with an implementation.

Thinking on it more though, it may be better to just save it user settings similar to the table settings.
Allowing users to seamlessly set up their search filters in a preferred way without hassling the admins. This would probably be more useful for the wider netbox community.

@PaulLocksley commented on GitHub (Jul 11, 2025): Hey @jeremystretch , yeah they are available, that was never in question, it's just a pain point for our users. >You don't specify how the proposed configuration would be achieved I did specify the configuration, please see the section in the issue body: > > This may be configured via a new setting such as DEFAULT_OBJECT_SELECTION_FIELDS > and look something like > > DEFAULT_OBJECT_SELECTION_FIELDS = { > 'dcim.Site': [ > 'filter_id'. 'q', 'region_id', 'group_id', 'cf_custom_field_name' > ] > } > And the further comment above containing a branch with an implementation. Thinking on it more though, it may be better to just save it user settings similar to the table settings. Allowing users to seamlessly set up their search filters in a preferred way without hassling the admins. This would probably be more useful for the wider netbox community.
Author
Owner

@jeremystretch commented on GitHub (Jul 14, 2025):

I'm sorry but I just don't see the value here, especially as a static configuration.

@jeremystretch commented on GitHub (Jul 14, 2025): I'm sorry but I just don't see the value here, especially as a static configuration.
Author
Owner

@arthanson commented on GitHub (Jul 31, 2025):

Closing as per above comments.

@arthanson commented on GitHub (Jul 31, 2025): Closing as per above comments.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11290