summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Graham <timograham@gmail.com>2011-05-15 19:12:29 +0000
committerTimo Graham <timograham@gmail.com>2011-05-15 19:12:29 +0000
commit5be8fdb03e9912516614f0b4c5f8b51003c1b771 (patch)
tree9e73477039a33d2e50d68b9f86116549fca0ca05
parent8385b31c8989e7f44d545b58a3904bdfd86ac8e8 (diff)
[1.3.X] Fixed #15769 - Documented FormWizard's initial argument; thanks aimaz for the suggestion; jrothenbuhler for the patch.
Backport of r16229 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16230 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--docs/ref/contrib/formtools/form-wizard.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
index 15680029f3..0416728409 100644
--- a/docs/ref/contrib/formtools/form-wizard.txt
+++ b/docs/ref/contrib/formtools/form-wizard.txt
@@ -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!'}