Skip to content

Commit

Permalink
Fixes #4043: Fix toggling of required fields in custom scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Jan 29, 2020
1 parent 1849473 commit e0d538a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions docs/release-notes/version-2.7.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v2.7.4 (FUTURE)

## Bug Fixes

* [#4043](https://github.com/netbox-community/netbox/issues/4043) - Fix toggling of required fields in custom scripts

---

# v2.7.3 (2020-01-28)

## Enhancements
Expand Down
9 changes: 5 additions & 4 deletions netbox/extras/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ def __init__(self, label='', description='', default=None, required=True):
# Initialize field attributes
if not hasattr(self, 'field_attrs'):
self.field_attrs = {}
if description:
self.field_attrs['help_text'] = description
if label:
self.field_attrs['label'] = label
if description:
self.field_attrs['help_text'] = description
if default:
self.field_attrs['initial'] = default
if required:
self.field_attrs['required'] = True
self.field_attrs['required'] = required

# Initialize the list of optional validators if none have already been defined
if 'validators' not in self.field_attrs:
self.field_attrs['validators'] = []

Expand Down

0 comments on commit e0d538a

Please sign in to comment.