Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15769 - Documented FormWizard's initial argument; thanks aimaz…

… 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...
commit ce6072aa963a0a8ec9e4330668f3ffecb907411b 1 parent 07bfc76
Tim Graham authored May 15, 2011
25  docs/ref/contrib/formtools/form-wizard.txt
@@ -308,3 +308,28 @@ Advanced ``FormWizard`` methods
308 308
 
309 309
         def process_step(self, request, form, step):
310 310
             # ...
  311
+
  312
+Providing initial data for the forms
  313
+====================================
  314
+
  315
+.. attribute:: FormWizard.initial
  316
+
  317
+    Initial data for a wizard's :class:`~django.forms.Form` objects can be
  318
+    provided using the optional :attr:`~FormWizard.initial` keyword argument.
  319
+    This argument should be a dictionary mapping a step to a dictionary
  320
+    containing the initial data for that step. The dictionary of initial data
  321
+    will be passed along to the constructor of the step's
  322
+    :class:`~django.forms.Form`::
  323
+
  324
+        >>> from testapp.forms import ContactForm1, ContactForm2, ContactWizard
  325
+        >>> initial = {
  326
+        ...     0: {'subject': 'Hello', 'sender': 'user@example.com'},
  327
+        ...     1: {'message': 'Hi there!'}
  328
+        ... }
  329
+        >>> wiz = ContactWizard([ContactForm1, ContactForm2], initial=initial)
  330
+        >>> form1 = wiz.get_form(0)
  331
+        >>> form2 = wiz.get_form(1)
  332
+        >>> form1.initial
  333
+        {'sender': 'user@example.com', 'subject': 'Hello'}
  334
+        >>> form2.initial
  335
+        {'message': 'Hi there!'}

0 notes on commit ce6072a

Please sign in to comment.
Something went wrong with that request. Please try again.