=== modified file 'django/newforms/forms.py'
|
|
|
187 | 187 | value = field.clean(value) |
188 | 188 | self.cleaned_data[name] = value |
189 | 189 | if hasattr(self, 'clean_%s' % name): |
190 | | value = getattr(self, 'clean_%s' % name)() |
| 190 | value = getattr(self, 'clean_%s' % name)(value) |
191 | 191 | self.cleaned_data[name] = value |
192 | 192 | except ValidationError, e: |
193 | 193 | errors[name] = e.messages |
=== modified file 'tests/regressiontests/forms/tests.py'
|
|
|
2434 | 2434 | Validation errors are HTML-escaped when output as HTML. |
2435 | 2435 | >>> class EscapingForm(Form): |
2436 | 2436 | ... special_name = CharField() |
2437 | | ... def clean_special_name(self): |
2438 | | ... raise ValidationError("Something's wrong with '%s'" % self.cleaned_data['special_name']) |
| 2437 | ... def clean_special_name(self, value): |
| 2438 | ... raise ValidationError("Something's wrong with '%s'" % value) |
2439 | 2439 | |
2440 | 2440 | >>> f = EscapingForm({'special_name': "Nothing to escape"}, auto_id=False) |
2441 | 2441 | >>> print f |
… |
… |
|
2457 | 2457 | ... username = CharField(max_length=10) |
2458 | 2458 | ... password1 = CharField(widget=PasswordInput) |
2459 | 2459 | ... password2 = CharField(widget=PasswordInput) |
2460 | | ... def clean_password2(self): |
2461 | | ... if self.cleaned_data.get('password1') and self.cleaned_data.get('password2') and self.cleaned_data['password1'] != self.cleaned_data['password2']: |
| 2460 | ... def clean_password2(self, value): |
| 2461 | ... if self.cleaned_data.get('password1') and self.cleaned_data.get('password2') and self.cleaned_data['password1'] != value: |
2462 | 2462 | ... raise ValidationError(u'Please make sure your passwords match.') |
2463 | | ... return self.cleaned_data['password2'] |
| 2463 | ... return value |
2464 | 2464 | >>> f = UserRegistration(auto_id=False) |
2465 | 2465 | >>> f.errors |
2466 | 2466 | {} |