mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 05:28:16 -06:00
14467 change ChoiceField separator from comma to colon
This commit is contained in:
parent
e59ee3e01e
commit
8d4001ef33
@ -95,8 +95,8 @@ class CustomFieldChoiceSetForm(BootstrapMixin, forms.ModelForm):
|
|||||||
required=False,
|
required=False,
|
||||||
help_text=mark_safe(_(
|
help_text=mark_safe(_(
|
||||||
'Enter one choice per line. An optional label may be specified for each choice by appending it with a '
|
'Enter one choice per line. An optional label may be specified for each choice by appending it with a '
|
||||||
'comma. Example:'
|
'colon. Example:'
|
||||||
) + ' <code>choice1,First Choice</code>')
|
) + ' <code>choice1:First Choice</code>')
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -107,7 +107,7 @@ class CustomFieldChoiceSetForm(BootstrapMixin, forms.ModelForm):
|
|||||||
data = []
|
data = []
|
||||||
for line in self.cleaned_data['extra_choices'].splitlines():
|
for line in self.cleaned_data['extra_choices'].splitlines():
|
||||||
try:
|
try:
|
||||||
value, label = line.split(',', maxsplit=1)
|
value, label = line.split(':', maxsplit=1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
value, label = line, line
|
value, label = line, line
|
||||||
data.append((value, label))
|
data.append((value, label))
|
||||||
|
@ -65,5 +65,5 @@ class ChoicesWidget(forms.Textarea):
|
|||||||
if not value:
|
if not value:
|
||||||
return None
|
return None
|
||||||
if type(value) is list:
|
if type(value) is list:
|
||||||
return '\n'.join([f'{k},{v}' for k, v in value])
|
return '\n'.join([f'{k}:{v}' for k, v in value])
|
||||||
return value
|
return value
|
||||||
|
Loading…
Reference in New Issue
Block a user