mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 17:26:10 -06:00
Misc cleanup
This commit is contained in:
parent
3219015a35
commit
b0144d1bd8
@ -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.
|
`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`
|
### `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.
|
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.
|
||||||
|
@ -52,21 +52,11 @@
|
|||||||
{% for group, fields in script.Meta.fieldsets %}
|
{% for group, fields in script.Meta.fieldsets %}
|
||||||
<div class="field-group mb-5">
|
<div class="field-group mb-5">
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<h5 class="offset-sm-3">
|
<h5 class="offset-sm-3">{{ group }}</h5>
|
||||||
{% if group %}
|
|
||||||
{{ group }}
|
|
||||||
{% else %}
|
|
||||||
{{ model|meta:"verbose_name"|bettertitle }}
|
|
||||||
{% endif %}
|
|
||||||
</h5>
|
|
||||||
</div>
|
</div>
|
||||||
{% for name in fields %}
|
{% for name in fields %}
|
||||||
{% with field=form|getfield:name %}
|
{% with field=form|getfield:name %}
|
||||||
{% if field.name in form.nullable_fields %}
|
{% render_field field %}
|
||||||
{% render_field field bulk_nullable=True %}
|
|
||||||
{% else %}
|
|
||||||
{% render_field field %}
|
|
||||||
{% endif %}
|
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user