Highlight field labels in forms when CUSTOM_VALIDATORS defined with field required:True #11889

Open
opened 2025-12-29 21:51:14 +01:00 by adam · 1 comment
Owner

Originally created by @simonzsay on GitHub (Dec 3, 2025).

NetBox version

v4.4.6

Feature type

New functionality

Proposed functionality

I’m trying to make several fields required in NetBox forms, even though they are not mandatory by default. According to the documentation, this should be possible using CUSTOM_VALIDATORS. I tested the following configuration on a development server (extra.py):

CUSTOM_VALIDATORS = {
    "dcim.site": [
        {
            "region": {"required": True},
            "tenant": {"required": True},
            "time_zone": {"required": True},
            "physical_address": {"required": True},
            "shipping_address": {"required": True},
            "facility": {"required": True},
        },
    ],

    "dcim.location": [
        {
            "tenant": {"required": True},
        },
    ],

    "dcim.rack": [
        {
            "location": {"required": True},
            "role": {"required": True},
            "tenant": {"required": True},
        },
    ],

    "dcim.rackreservation": [
        {
            "tenant": {"required": True},
        },
    ],

    "dcim.device": [
        {
            "name": {"required": True},
            "tenant": {"required": True},
            "location": {"required": True},
            "rack": {"required": True},
        },
    ],
}

Functionally everything works — validation correctly prevents saving objects when these fields are empty.

However, the UI does not indicate that these fields are required.
For example, with the following configuration:

"dcim.device": [
    {
        "tenant": {"required": True},
    }
]
Image

Will be great to see it bold and with star *, like this

Image

When user skips some field in the form he can see notification in UI, but for only first validated field. He fills this field, click "save" and again get new validation error with next field.

Image

Use case

Current way quite confusing for users because the field appears optional, but the form fails to submit unless it is filled in. With offered way where all "custom required fields" have bold text and star *, form will be filled from first attempt instead of 2-3 or even more.

Database changes

Sorry, i can`t provide details about data base.

External dependencies

Sorry, i can`t provide details about dependencies.

Originally created by @simonzsay on GitHub (Dec 3, 2025). ### NetBox version v4.4.6 ### Feature type New functionality ### Proposed functionality I’m trying to make several fields required in NetBox forms, even though they are not mandatory by default. According to the documentation, this should be possible using CUSTOM_VALIDATORS. I tested the following configuration on a development server (extra.py): ``` CUSTOM_VALIDATORS = { "dcim.site": [ { "region": {"required": True}, "tenant": {"required": True}, "time_zone": {"required": True}, "physical_address": {"required": True}, "shipping_address": {"required": True}, "facility": {"required": True}, }, ], "dcim.location": [ { "tenant": {"required": True}, }, ], "dcim.rack": [ { "location": {"required": True}, "role": {"required": True}, "tenant": {"required": True}, }, ], "dcim.rackreservation": [ { "tenant": {"required": True}, }, ], "dcim.device": [ { "name": {"required": True}, "tenant": {"required": True}, "location": {"required": True}, "rack": {"required": True}, }, ], } ``` Functionally everything works — validation correctly prevents saving objects when these fields are empty. However, the UI does not indicate that these fields are required. For example, with the following configuration: ``` "dcim.device": [ { "tenant": {"required": True}, } ] ``` <img width="576" height="73" alt="Image" src="https://github.com/user-attachments/assets/1e60de11-99ab-4c64-8195-20e6e942d9fe" /> Will be great to see it bold and with star *, like this <img width="187" height="38" alt="Image" src="https://github.com/user-attachments/assets/d4e46c7a-967c-424d-8085-124b93292571" /> When user skips some field in the form he can see notification in UI, but for only first validated field. He fills this field, click "save" and again get new validation error with next field. <img width="302" height="105" alt="Image" src="https://github.com/user-attachments/assets/61f76795-3555-4cd6-be39-154e01cec4ff" /> ### Use case Current way quite confusing for users because the field appears optional, but the form fails to submit unless it is filled in. With offered way where all "custom required fields" have bold text and star *, form will be filled from first attempt instead of 2-3 or even more. ### Database changes Sorry, i can`t provide details about data base. ### External dependencies Sorry, i can`t provide details about dependencies.
adam added the type: featurestatus: needs ownercomplexity: mediumnetbox labels 2025-12-29 21:51:14 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 4, 2025):

While I like the idea in principle, this might prove tricky to implement because there's no direct correlation from individual forms to custom validators. We could try to stitch them together, but care will be needed to avoid enforcing custom validators for any object attributes are not being modified by the form.

@jeremystretch commented on GitHub (Dec 4, 2025): While I like the idea in principle, this might prove tricky to implement because there's no direct correlation from individual forms to custom validators. We could try to stitch them together, but care will be needed to avoid enforcing custom validators for any object attributes are not being modified by the form.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11889