Editing a Custom Field with Default Value does not pre-populate form with correct value #10726

Closed
opened 2025-12-29 21:35:16 +01:00 by adam · 3 comments
Owner

Originally created by @mattg66 on GitHub (Feb 3, 2025).

Originally assigned to: @renatoalmeidaoliveira on GitHub.

Deployment Type

NetBox Docker

NetBox Version

v4.2.2

Python Version

3.10

Steps to Reproduce

Create a custom field with a selection type.
Populate the default value with a string such as "Test"
Save the custom field.

Edit the custom field and the Default Value is populated with Test without the quotations, leading to the forms validation failing. Manually adding the quotations to read "Test" allows the form to be submitted

Expected Behavior

The Default Value textarea should be populated with valid JSON

Observed Behavior

The Default Value textarea is not populated with valid JSON leading to the form validation failing.

Originally created by @mattg66 on GitHub (Feb 3, 2025). Originally assigned to: @renatoalmeidaoliveira on GitHub. ### Deployment Type NetBox Docker ### NetBox Version v4.2.2 ### Python Version 3.10 ### Steps to Reproduce Create a custom field with a selection type. Populate the default value with a string such as "Test" Save the custom field. Edit the custom field and the Default Value is populated with Test without the quotations, leading to the forms validation failing. Manually adding the quotations to read "Test" allows the form to be submitted ### Expected Behavior The Default Value textarea should be populated with valid JSON ### Observed Behavior The Default Value textarea is not populated with valid JSON leading to the form validation failing.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:35:16 +01:00
adam closed this issue 2025-12-29 21:35:16 +01:00
Author
Owner

@DanSheps commented on GitHub (Feb 4, 2025):

The default value is used when there is no value set. It does not make sense to pre-populate the field with the default value, IMO.

@DanSheps commented on GitHub (Feb 4, 2025): The default value is used when there is no value set. It does not make sense to pre-populate the field with the default value, IMO.
Author
Owner

@mattg66 commented on GitHub (Feb 5, 2025):

Hi, This is during the editing of a custom field:

Image

Whereas the entered JSON is the following:

Image

@mattg66 commented on GitHub (Feb 5, 2025): Hi, This is during the editing of a custom field: ![Image](https://github.com/user-attachments/assets/4c78a7b3-d398-4120-ad63-e63304af9695) Whereas the entered JSON is the following: ![Image](https://github.com/user-attachments/assets/53c7b7b7-feba-4b88-b28e-8362b6518819)
Author
Owner

@DanSheps commented on GitHub (Feb 5, 2025):

Okay, I see what you mean now.

Looks like the quotes are being removed from the json field. Not sure why but yes, that is a bug.

@DanSheps commented on GitHub (Feb 5, 2025): Okay, I see what you mean now. Looks like the quotes are being removed from the json field. Not sure why but yes, that is a bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10726