Skip to content

Commit

Permalink
Fixed #15769 - Documented FormWizard's initial argument; thanks aimaz…
Browse files Browse the repository at this point in the history
… for the suggestion; jrothenbuhler for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16229 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
timgraham committed May 15, 2011
1 parent 07bfc76 commit ce6072a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/ref/contrib/formtools/form-wizard.txt
Expand Up @@ -308,3 +308,28 @@ Advanced ``FormWizard`` methods

def process_step(self, request, form, step):
# ...

Providing initial data for the forms
====================================

.. attribute:: FormWizard.initial

Initial data for a wizard's :class:`~django.forms.Form` objects can be
provided using the optional :attr:`~FormWizard.initial` keyword argument.
This argument should be a dictionary mapping a step to a dictionary
containing the initial data for that step. The dictionary of initial data
will be passed along to the constructor of the step's
:class:`~django.forms.Form`::

>>> from testapp.forms import ContactForm1, ContactForm2, ContactWizard
>>> initial = {
... 0: {'subject': 'Hello', 'sender': 'user@example.com'},
... 1: {'message': 'Hi there!'}
... }
>>> wiz = ContactWizard([ContactForm1, ContactForm2], initial=initial)
>>> form1 = wiz.get_form(0)
>>> form2 = wiz.get_form(1)
>>> form1.initial
{'sender': 'user@example.com', 'subject': 'Hello'}
>>> form2.initial
{'message': 'Hi there!'}

0 comments on commit ce6072a

Please sign in to comment.