Permalink
Browse files

Fixed #16479.

Patch with tests from charettes, updated.
  • Loading branch information...
1 parent 55fa86a commit 9719522f9b6ce2ac5f50b8b58891f12ec4406462 @vicould committed Oct 4, 2012
Showing with 15 additions and 1 deletion.
  1. +5 −1 django/forms/formsets.py
  2. +10 −0 tests/regressiontests/forms/tests/formsets.py
View
@@ -123,7 +123,11 @@ def _construct_form(self, i, **kwargs):
"""
Instantiates and returns the i-th form instance in a formset.
"""
- defaults = {'auto_id': self.auto_id, 'prefix': self.add_prefix(i)}
+ defaults = {
+ 'auto_id': self.auto_id,
+ 'prefix': self.add_prefix(i),
+ 'error_class': self.error_class,
+ }
if self.is_bound:
defaults['data'] = self.data
defaults['files'] = self.files
@@ -3,6 +3,7 @@
from django.forms import Form, CharField, IntegerField, ValidationError, DateField
from django.forms.formsets import formset_factory, BaseFormSet
+from django.forms.util import ErrorList
from django.test import TestCase
@@ -847,6 +848,15 @@ def test_formset_nonzero(self):
self.assertTrue(formset)
+ def test_formset_error_class(self):
+ # Regression tests for #16479 -- formsets form use ErrorList instead of supplied error_class
+ class CustomErrorList(ErrorList):
+ pass
+
+ formset = FavoriteDrinksFormSet(error_class=CustomErrorList)
+ self.assertEqual(formset.forms[0].error_class, CustomErrorList)
+
+
data = {
'choices-TOTAL_FORMS': '1', # the number of forms rendered
'choices-INITIAL_FORMS': '0', # the number of forms with initial data

1 comment on commit 9719522

This patch contains tabs (and mixed with spaces! evil!). Other than this looks good, I'll fix the tabs when I commit

Please sign in to comment.