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

Rows with only hidden inputs are displayed in admin forms #295

Open
jackh-step opened this issue Sep 6, 2024 · 2 comments
Open

Rows with only hidden inputs are displayed in admin forms #295

jackh-step opened this issue Sep 6, 2024 · 2 comments

Comments

@jackh-step
Copy link

jackh-step commented Sep 6, 2024

Rows containing only hidden inputs in admin forms are being displayed despite having the "hidden" class.
This is related to "base.css" file containing the "hidden" class selector being shadowed.

@abidibo
Copy link
Member

abidibo commented Sep 6, 2024

Hi @jackh-step please provide a sample code with just Model and ModelAdmin. Thanks

@jackh-step
Copy link
Author

Hi @abidibo, thanks for responding, here's an example for reproduction.

class MyModel(models.Model):
    field = models.BooleanField()
    hidden_field = models.BooleanField()

class MyModelForm(forms.ModelForm):
    class Meta:
        model = models.MyModel
        fields = "__all__"
        widgets = {
            "hidden_field": forms.HiddenInput()
        }

@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    form = MyModelForm

In the above admin, even though the bottom row only contains a hidden input, it is still displayed for the reasons mentioned previously.
The "hidden" class is applied if a fieldset's line has has_visible_field set to False, link to fieldset template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants