| | 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!'} |