mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Introduce local ChoiceField and MultipleChoiceField classes
This commit is contained in:
@ -9,11 +9,13 @@ from utilities.forms import widgets
|
||||
from utilities.validators import EnhancedURLValidator
|
||||
|
||||
__all__ = (
|
||||
'ChoiceField',
|
||||
'ColorField',
|
||||
'CommentField',
|
||||
'JSONField',
|
||||
'LaxURLField',
|
||||
'MACAddressField',
|
||||
'MultipleChoiceField',
|
||||
'SlugField',
|
||||
'TagFilterField',
|
||||
)
|
||||
@ -125,3 +127,21 @@ class MACAddressField(forms.Field):
|
||||
raise forms.ValidationError(self.error_messages['invalid'], code='invalid')
|
||||
|
||||
return value
|
||||
|
||||
|
||||
#
|
||||
# Choice fields
|
||||
#
|
||||
|
||||
class ChoiceField(forms.ChoiceField):
|
||||
"""
|
||||
Overrides Django's built-in `ChoiceField` to use NetBox's `StaticSelect` widget
|
||||
"""
|
||||
widget = widgets.StaticSelect
|
||||
|
||||
|
||||
class MultipleChoiceField(forms.MultipleChoiceField):
|
||||
"""
|
||||
Overrides Django's built-in `MultipleChoiceField` to use NetBox's `StaticSelectMultiple` widget
|
||||
"""
|
||||
widget = widgets.StaticSelectMultiple
|
||||
|
Reference in New Issue
Block a user