Skip to content

Commit

Permalink
Fixed #20326 - Corrected form wizard get_form() example.
Browse files Browse the repository at this point in the history
Thanks tris@ for the report.
  • Loading branch information
timgraham committed May 31, 2013
1 parent f513764 commit 646a221
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/ref/contrib/formtools/form-wizard.txt
Expand Up @@ -420,8 +420,10 @@ Advanced ``WizardView`` methods
.. method:: WizardView.get_form(step=None, data=None, files=None) .. method:: WizardView.get_form(step=None, data=None, files=None)


This method constructs the form for a given ``step``. If no ``step`` is This method constructs the form for a given ``step``. If no ``step`` is
defined, the current step will be determined automatically. defined, the current step will be determined automatically. If you override
The method gets three arguments: ``get_form``, however, you will need to set ``step`` yourself using
``self.steps.current`` as in the example below. The method gets three
arguments:


* ``step`` -- The step for which the form instance should be generated. * ``step`` -- The step for which the form instance should be generated.
* ``data`` -- Gets passed to the form's data argument * ``data`` -- Gets passed to the form's data argument
Expand All @@ -433,6 +435,11 @@ Advanced ``WizardView`` methods


def get_form(self, step=None, data=None, files=None): def get_form(self, step=None, data=None, files=None):
form = super(MyWizard, self).get_form(step, data, files) form = super(MyWizard, self).get_form(step, data, files)

# determine the step if not given
if step is None:
step = self.steps.current

if step == '1': if step == '1':
form.user = self.request.user form.user = self.request.user
return form return form
Expand Down

0 comments on commit 646a221

Please sign in to comment.