Kaydet (Commit) 69e6045c authored tarafından Tim Graham's avatar Tim Graham

[1.8.x] Fixed #25597 -- Fixed crash with SplitArrayField and IntegerField on invalid value.

Backport of 1f07da3e from master
üst 6b631b5c
......@@ -166,7 +166,7 @@ class SplitArrayField(forms.Field):
errors.append(None)
except ValidationError as error:
errors.append(ValidationError(
string_concat(self.error_messages['item_invalid'], error.message),
string_concat(self.error_messages['item_invalid'], ' '.join(error.messages)),
code='item_invalid',
params={'nth': i},
))
......
......@@ -38,3 +38,6 @@ Bugfixes
* Fixed a typo in the name of the `strictly_above` PostGIS lookup
(:ticket:`25592`).
* Fixed crash with ``contrib.postgres.forms.SplitArrayField`` and
``IntegerField`` on invalid value (:ticket:`25597`).
......@@ -484,6 +484,11 @@ class TestSplitFormField(TestCase):
self.assertFalse(form.is_valid())
self.assertEqual(form.errors, {'array': ['Item 2 in the array did not validate: This field is required.']})
def test_invalid_integer(self):
msg = 'Item 1 in the array did not validate: Ensure this value is less than or equal to 100.'
with self.assertRaisesMessage(exceptions.ValidationError, msg):
SplitArrayField(forms.IntegerField(max_value=100), size=2).clean([0, 101])
def test_rendering(self):
class SplitForm(forms.Form):
array = SplitArrayField(forms.CharField(), size=3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment