-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox version
v3.1.4
Feature type
Change to existing functionality
Proposed functionality
When you set required=False on a ChoiceVar, have no choice selected by default, and allow the user not to select anything.
Currently, if you have e.g.
cable_color = ChoiceVar(choices=ColorChoices.CHOICES, required=False, label="Cable Color")
then there is an arbitrary color chosen by default, and the user is required to select one.
Use case
For using built-in choices like CableTypeChoices.CHOICES or ColorChoices.CHOICES where no choice is a valid selection.
Workaround:
NO_CHOICE = (
('', '---------'),
)
cable_color = ChoiceVar(choices=NO_CHOICE+ColorChoices.CHOICES, required=False, label="Cable Color")
(Note however that required=False is still required)
Database changes
None
External dependencies
None
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application