Cannot add a new custom field of type selection/multiple selection list #8574

Closed
opened 2025-12-29 20:38:19 +01:00 by adam · 3 comments
Owner

Originally created by @DanSheps on GitHub (Sep 5, 2023).

Originally assigned to: @DanSheps on GitHub.

NetBox version

v3.6.0

Python version

3.9

Steps to Reproduce

  1. Add a choice field set named Test with the following choices:
    test,Test
    tester,Tester
    testing,Testing
    
  2. Add a custom field
    a. Name: Test
    b: Object: Circuits
    c: Type: Multiple Selection (Selection also has an issue)
    d: Required: True
    e: Default: "test"
    f: Choice Set: Test
  3. Save

Expected Behavior

Custom Field Saves

Observed Behavior

AttributeError: 'CustomField' object has no attribute 'message'

Nested Exception:
ValidationError: Invalid choice(s) (t, e, s, t). Available choices are:

Alternatively, if default is set to "", the nested exception is:

ValidationError: 'Required field cannot be empty.'

Originally created by @DanSheps on GitHub (Sep 5, 2023). Originally assigned to: @DanSheps on GitHub. ### NetBox version v3.6.0 ### Python version 3.9 ### Steps to Reproduce 1. Add a choice field set named Test with the following choices: ```` test,Test tester,Tester testing,Testing ```` 3. Add a custom field a. Name: Test b: Object: Circuits c: Type: Multiple Selection (Selection also has an issue) d: Required: True e: Default: "test" f: Choice Set: Test 4. Save ### Expected Behavior Custom Field Saves ### Observed Behavior `AttributeError: 'CustomField' object has no attribute 'message'` Nested Exception: `ValidationError: Invalid choice(s) (t, e, s, t). Available choices are: ` Alternatively, if default is set to "", the nested exception is: `ValidationError: 'Required field cannot be empty.'`
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 20:38:20 +01:00
adam closed this issue 2025-12-29 20:38:20 +01:00
Author
Owner

@DanSheps commented on GitHub (Sep 5, 2023):

Turns out, the list was added wrong on my end my end as well, resulting in some of the problems. Updated to reflect the problem more specifically.

That said, there is an issue with the validation still of a default field. self.default and self.default not in self.choices: won't work

We could actually remove line 321 to 326 as that validation logic is also part of the default check at the top.

@DanSheps commented on GitHub (Sep 5, 2023): Turns out, the list was added wrong on my end my end as well, resulting in some of the problems. Updated to reflect the problem more specifically. That said, there is an issue with the validation still of a default field. `self.default and self.default not in self.choices:` won't work We could actually remove line 321 to 326 as that validation logic is also part of the default check at the top.
Author
Owner

@wypxl commented on GitHub (Sep 8, 2023):

Hi, i dont know how to add a choice field,I can't find the button on the netbox,can you tell me how to define a choice filed?

@wypxl commented on GitHub (Sep 8, 2023): Hi, i dont know how to add a choice field,I can't find the button on the netbox,can you tell me how to define a choice filed?
Author
Owner

@DanSheps commented on GitHub (Sep 8, 2023):

You should Read the Docs

@DanSheps commented on GitHub (Sep 8, 2023): You should [Read the Docs](https://docs.netbox.dev/en/stable/customization/custom-fields/#custom-selection-fields)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8574