Ticket #7222: preview.diff

File preview.diff, 2.3 KB (added by Samuel Cormier-Iijima <sciyoshi@…>, 16 years ago)
  • django/contrib/formtools/preview.py

     
    7070        if f.is_valid():
    7171            if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')):
    7272                return self.failed_hash(request) # Security hash failed.
    73             return self.done(request, f.cleaned_data)
     73            return self.done(request, f)
    7474        else:
    7575            return render_to_response(self.form_template,
    7676                {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state},
  • docs/form_preview.txt

     
    2121       a. If it's valid, displays a preview page.
    2222       b. If it's not valid, redisplays the form with error messages.
    2323    3. When the "confirmation" form is submitted from the preview page, calls
    24        a hook that you define -- a ``done()`` method that gets passed the valid
    25        data.
     24       a hook that you define -- a ``done()`` method that gets passed the form
     25       instance.
    2626
    2727The framework enforces the required preview by passing a shared-secret hash to
    2828the preview page via hidden form fields. If somebody tweaks the form parameters
     
    5050
    5151           class SomeModelFormPreview(FormPreview):
    5252
    53                def done(self, request, cleaned_data):
    54                    # Do something with the cleaned_data, then redirect
     53               def done(self, request, form):
     54                   # Do something with form or form.cleaned_data, then redirect
    5555                   # to a "success" page.
    5656                   return HttpResponseRedirect('/form/success')
    5757
    58        This method takes an ``HttpRequest`` object and a dictionary of the form
    59        data after it has been validated and cleaned. It should return an
     58       This method takes an ``HttpRequest`` object and an bound instance of the
     59       form class after having been validated and cleaned. It should return an
    6060       ``HttpResponseRedirect`` that is the end result of the form being
    6161       submitted.
    6262
Back to Top