diff --git a/docs/customization/custom-scripts.md b/docs/customization/custom-scripts.md
index 1051b31f6..7774ef35f 100644
--- a/docs/customization/custom-scripts.md
+++ b/docs/customization/custom-scripts.md
@@ -308,6 +308,7 @@ A particular object within NetBox. Each ObjectVar must specify a particular mode
* `query_params` - A dictionary of query parameters to use when retrieving available options (optional)
* `context` - A custom dictionary mapping template context variables to fields, used when rendering `` elements within the dropdown menu (optional; see below)
* `null_option` - A label representing a "null" or empty choice (optional)
+* `selector` - A boolean that, when True, includes an advanced object selection widget to assist the user in identifying the desired object (optional; False by default)
To limit the selections available within the list, additional query parameters can be passed as the `query_params` dictionary. For example, to show only devices with an "active" status:
diff --git a/netbox/extras/scripts.py b/netbox/extras/scripts.py
index 0d9c2181f..2d3f96254 100644
--- a/netbox/extras/scripts.py
+++ b/netbox/extras/scripts.py
@@ -211,10 +211,12 @@ class ObjectVar(ScriptVariable):
:param context: A custom dictionary mapping template context variables to fields, used when rendering
elements within the dropdown menu (optional)
:param null_option: The label to use as a "null" selection option (optional)
+ :param selector: Include an advanced object selection widget to assist the user in identifying the desired
+ object (optional)
"""
form_field = DynamicModelChoiceField
- def __init__(self, model, query_params=None, context=None, null_option=None, *args, **kwargs):
+ def __init__(self, model, query_params=None, context=None, null_option=None, selector=False, *args, **kwargs):
super().__init__(*args, **kwargs)
self.field_attrs.update({
@@ -222,6 +224,7 @@ class ObjectVar(ScriptVariable):
'query_params': query_params,
'context': context,
'null_option': null_option,
+ 'selector': selector,
})
diff --git a/netbox/templates/extras/script.html b/netbox/templates/extras/script.html
index ff01cc59a..220a9d714 100644
--- a/netbox/templates/extras/script.html
+++ b/netbox/templates/extras/script.html
@@ -54,3 +54,7 @@
{% endblock content %}
+
+{% block modals %}
+ {% include 'inc/htmx_modal.html' with size='lg' %}
+{% endblock %}