Reputation: 49866
I have several formsets to which I am passing error_class
es, but the formset is just not using the specified class to render errors.
The error_class works for standalone forms (such as form
in the below snippet).
I'm using Django 1.3. Is there a way to get formsets to do this?
My view code:
form = IncorporateForm(request.POST, error_class=SideError)
guarantee_form = GuaranteeForm(data=request.POST, error_class=SideError)
directors_formset = DirectorsFormset(prefix='directors', data=request.POST, error_class=SideError\
)
capital_formset = CapitalFormset(prefix='capital', data=request.POST, error_class=SideError)
holding_formset = HoldingFormset(prefix='holding', data=request.POST, error_class=SideError)
amends_formset = AmendsFormset(prefix='amends', data=request.POST, error_class=SideError)
Upvotes: 1
Views: 157
Reputation: 49866
I've discovered that Formset does not pass down the error_class to the forms it creates.
I've created this ticket: https://code.djangoproject.com/ticket/16479 That ticket details the fix, which is to change the first line in Formset._construct_form to:
defaults = {'auto_id': self.auto_id, 'prefix': self.add_prefix(i), 'error_class': self.error_class}
That passes the error_class to each form created.
Upvotes: 1