Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
LinzerToertchen opened this issue Jan 29, 2020 · 1 comment
Closed
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@LinzerToertchen
Copy link

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.

LinzerToertchen pushed a commit to LinzerToertchen/netbox that referenced this issue Jan 29, 2020
@jeremystretch jeremystretch changed the title Non-Required fields are required in 2.7.3's custom scripts Setting required=False on a custom script variable has no effect Jan 29, 2020
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Jan 29, 2020
@jeremystretch
Copy link
Member

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

@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants