diff --git a/docs/customization/custom-scripts.md b/docs/customization/custom-scripts.md index fd6e81250..ccbe50885 100644 --- a/docs/customization/custom-scripts.md +++ b/docs/customization/custom-scripts.md @@ -85,6 +85,17 @@ By default, script variables will be ordered in the form as they are defined in `fieldsets` may be defined as an iterable of field groups and their field names to determine the order in which variables are group and rendered. Any fields not included in this iterable will not be displayed in the form. If `fieldsets` is defined, `field_order` will be ignored. A fieldset group for "Script Execution Parameters" will be added to the end of the fieldsets by default for the user. +An example fieldset definition is provided below: + +```python +class MyScript(Script): + class Meta: + fieldsets = ( + ('First group', ('field1', 'field2', 'field3')), + ('Second group', ('field4', 'field5')), + ) +``` + ### `commit_default` The checkbox to commit database changes when executing a script is checked by default. Set `commit_default` to False under the script's Meta class to leave this option unchecked by default. diff --git a/netbox/templates/extras/script.html b/netbox/templates/extras/script.html index a6094a862..a7093ec15 100644 --- a/netbox/templates/extras/script.html +++ b/netbox/templates/extras/script.html @@ -52,21 +52,11 @@ {% for group, fields in script.Meta.fieldsets %}
-
- {% if group %} - {{ group }} - {% else %} - {{ model|meta:"verbose_name"|bettertitle }} - {% endif %} -
+
{{ group }}
{% for name in fields %} {% with field=form|getfield:name %} - {% if field.name in form.nullable_fields %} - {% render_field field bulk_nullable=True %} - {% else %} - {% render_field field %} - {% endif %} + {% render_field field %} {% endwith %} {% endfor %}