jrief / django-formset

The missing widgets and form manipulation library for Django
https://django-formset.fly.dev/
MIT License
317 stars 30 forks source link

FormCollection with readonly fields #97

Closed objectif-securite closed 9 months ago

objectif-securite commented 9 months ago

Hello, In a form where I want to display fields as readonly, I overrided the init method of the ModelForm and set something like this:

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields["serial"].disabled = True
        self.fields["serial"].required = False

It works as expected in a Form, but not in a FormCollection. In the latter, the value is taken into account and submitted to the DB.