Ticket #15769: 15769.diff

File 15769.diff, 1.4 KB (added by Jake Rothenbuhler, 13 years ago)
  • docs/ref/contrib/formtools/form-wizard.txt

     
    308308
    309309        def process_step(self, request, form, step):
    310310            # ...
     311
     312Providing 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!'}
Back to Top