Setting required=False on a custom script variable has no effect #3239

Closed
opened 2025-12-29 18:27:00 +01:00 by adam · 1 comment
Owner

Originally created by @LinzerToertchen on GitHub (Jan 29, 2020).

Using NetBox 2.7.3 all fields in custom scripts are required (in the html input the required flag is set, when sending it anyways NetBox reports that the field is required).

Environment

  • Python version: 3.7.6
  • NetBox version: 2.7.3

Steps to Reproduce

  1. Have a custom script with a field with required = False
  2. Try leaving the field empty
  3. Fail

Expected Behavior

The html input is not required and a submit with the field being empty succeeds.

Observed Behavior

The html input is required and a submit with the field being empty fails.

Originally created by @LinzerToertchen on GitHub (Jan 29, 2020). Using NetBox 2.7.3 all fields in custom scripts are required (in the html input the required flag is set, when sending it anyways NetBox reports that the field is required). # Environment * Python version: 3.7.6 * NetBox version: 2.7.3 ### Steps to Reproduce 1. Have a custom script with a field with `required = False` 2. Try leaving the field empty 3. Fail ### Expected Behavior The html input is not required and a submit with the field being empty succeeds. ### Observed Behavior The html input is required and a submit with the field being empty fails.
adam added the type: bugstatus: accepted labels 2025-12-29 18:27:00 +01:00
adam closed this issue 2025-12-29 18:27:00 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 29, 2020):

Will be fixed in v2.7.4, but as a temporary workaround you can do this:

class MyCustomScript(Script):
    foo = StringVar()

    def __init__(self):
        super().__init__()
        self.foo.field_attrs['required'] = False
@jeremystretch commented on GitHub (Jan 29, 2020): Will be fixed in v2.7.4, but as a temporary workaround you can do this: ```python class MyCustomScript(Script): foo = StringVar() def __init__(self): super().__init__() self.foo.field_attrs['required'] = False ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3239