Ticket #7222: preview.diff
File preview.diff, 2.3 KB (added by , 17 years ago) |
---|
-
django/contrib/formtools/preview.py
70 70 if f.is_valid(): 71 71 if self.security_hash(request, f) != request.POST.get(self.unused_name('hash')): 72 72 return self.failed_hash(request) # Security hash failed. 73 return self.done(request, f .cleaned_data)73 return self.done(request, f) 74 74 else: 75 75 return render_to_response(self.form_template, 76 76 {'form': f, 'stage_field': self.unused_name('stage'), 'state': self.state}, -
docs/form_preview.txt
21 21 a. If it's valid, displays a preview page. 22 22 b. If it's not valid, redisplays the form with error messages. 23 23 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 valid25 data.24 a hook that you define -- a ``done()`` method that gets passed the form 25 instance. 26 26 27 27 The framework enforces the required preview by passing a shared-secret hash to 28 28 the preview page via hidden form fields. If somebody tweaks the form parameters … … 50 50 51 51 class SomeModelFormPreview(FormPreview): 52 52 53 def done(self, request, cleaned_data):54 # Do something with thecleaned_data, then redirect53 def done(self, request, form): 54 # Do something with form or form.cleaned_data, then redirect 55 55 # to a "success" page. 56 56 return HttpResponseRedirect('/form/success') 57 57 58 This method takes an ``HttpRequest`` object and a dictionary of the form59 data after it hasbeen validated and cleaned. It should return an58 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 60 60 ``HttpResponseRedirect`` that is the end result of the form being 61 61 submitted. 62 62