Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicModelChoiceField doesn't render error message on submit #18916

Open
chii0815 opened this issue Mar 16, 2025 · 2 comments
Open

DynamicModelChoiceField doesn't render error message on submit #18916

chii0815 opened this issue Mar 16, 2025 · 2 comments
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@chii0815
Copy link

Deployment Type

Self-hosted

NetBox Version

v.4.2.5

Python Version

3.11

Steps to Reproduce

While developing a plugin I realized that the DynamicModelChoiceField doesn't display an error if required=True and the nothing is selected. The form just doesn't submit and the view doesn't give a hint why.

  1. create a form with two choice fields (one django.forms.ModelChoiceField and one DynamicModelChoiceField)
  2. set both to be required

Expected Behavior

When both are empty the form should show an error message on submit

Observed Behavior

only the forms.ModelChoiceField shows an error message

Image

@chii0815 chii0815 added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Mar 16, 2025
@chii0815
Copy link
Author

this is my py file for this form

from django import forms
from circuits.models import Provider
from tenancy.models import Tenant
from netbox.forms import NetBoxModelForm
from django.utils.translation import gettext_lazy as _
from utilities.forms.fields import DynamicModelChoiceField
from ..models import CVS

class CVSForm(NetBoxModelForm):

    provider = forms.ModelChoiceField(
        queryset = Provider.objects.all(),
        required = True,
        label = _('provider')
    )

    tenant = DynamicModelChoiceField(
        queryset = Tenant.objects.all(),
        required = True,
        selector= True,
        label= _('tenant')
    )  

    class Meta:
        model = CVS
        fields = ('name', 'provider', 'tenant', 'tags')

    def clean(self):
        super().clean()

@chii0815
Copy link
Author

chii0815 commented Mar 16, 2025

this also happens on netboxes dcim model device-types:

Image

@bctiemann bctiemann added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants