Ticket #17182: 17182b.diff

File 17182b.diff, 1.3 KB (added by Simon Meers, 13 years ago)

Added documentation note

  • docs/ref/forms/validation.txt

    diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt
    index 7657353..42006bb 100644
    a b example::  
    300300        ...
    301301
    302302        def clean(self):
    303             cleaned_data = self.cleaned_data
     303            cleaned_data = super(ContactForm, self).clean()
    304304            cc_myself = cleaned_data.get("cc_myself")
    305305            subject = cleaned_data.get("subject")
    306306
    example::  
    316316In this code, if the validation error is raised, the form will display an
    317317error message at the top of the form (normally) describing the problem.
    318318
     319Note that the call to ``super(ContactForm, self).clean()`` in the example code
     320ensures that any validation logic in parent classes is maintained.
     321
    319322The second approach might involve assigning the error message to one of the
    320323fields. In this case, let's assign an error message to both the "subject" and
    321324"cc_myself" rows in the form display. Be careful when doing this in practice,
    sample) looks like this::  
    329332        ...
    330333
    331334        def clean(self):
    332             cleaned_data = self.cleaned_data
     335            cleaned_data = super(ContactForm, self).clean()
    333336            cc_myself = cleaned_data.get("cc_myself")
    334337            subject = cleaned_data.get("subject")
    335338
Back to Top