1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #4710: Fix merging of form fields among custom scripts

This commit is contained in:
Jeremy Stretch
2020-06-15 14:20:00 -04:00
parent 5bcf85e57d
commit eaaaaec5a5
4 changed files with 12 additions and 20 deletions

View File

@@ -430,18 +430,9 @@ class ScriptForm(BootstrapMixin, forms.Form):
help_text="Commit changes to the database (uncheck for a dry-run)"
)
def __init__(self, vars, *args, commit_default=True, **kwargs):
# Dynamically populate fields for variables
for name, var in vars.items():
self.base_fields[name] = var.as_field()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Toggle default commit behavior based on Meta option
if not commit_default:
self.fields['_commit'].initial = False
# Move _commit to the end of the form
commit = self.fields.pop('_commit')
self.fields['_commit'] = commit