Opened 13 years ago
Closed 12 years ago
#16479 closed Bug (fixed)
Forms generated from formsets use ErrorList instead of supplied error_class
Reported by: | Owned by: | Simon Charette | |
---|---|---|---|
Component: | Forms | Version: | 1.3 |
Severity: | Normal | Keywords: | forms formsets |
Cc: | Ludovic Delaveau | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Using Django 1.3, forms generated from formsets use ErrorList instead of supplied error_class.
Accordingly, even though a formset is instantiated:
directors_formset = DirectorsFormset(prefix='directors',
data=request.POST,
error_class=SideError)
Forms generated from it use the default ErrorList ul style of error rendering.
The fix is in the first line of FormSet._construct_form, which currently reads:
defaults = {'auto_id': self.auto_id, 'prefix': self.add_prefix(i)}
(https://code.djangoproject.com/browser/django/trunk/django/forms/formsets.py#L114)
This should be changed to:
defaults = {'auto_id': self.auto_id, 'prefix': self.add_prefix(i), 'error_class': self.error_class}
Which passes the error_class down to every form instantiated.
Attachments (3)
Change History (13)
comment:1 by , 13 years ago
by , 13 years ago
Attachment: | 16479-formset-forms-error_class.diff added |
---|
comment:2 by , 13 years ago
Needs tests: | set |
---|
comment:3 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
by , 12 years ago
Attachment: | 16479-formset-forms-error_class-with-tests_updated.diff added |
---|
Updated test import
comment:6 by , 12 years ago
Updated part of the patch, which could not be applied anymore: changed the context of the additional import required by the test.
comment:7 by , 12 years ago
Needs tests: | unset |
---|
comment:8 by , 12 years ago
Cc: | added |
---|
comment:9 by , 12 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Looks ready for checkin, pull request at https://github.com/django/django/pull/423
comment:10 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Looks like a bug to me, can someone confirm? If it's accepted it'll need tests.