Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#20326 closed Cleanup/optimization (fixed)

Documentation for form wizard -> get_form()

Reported by: tris@… Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The description for this method mentions that 'If no step is defined, the current step will be determined automatically' but the example fails to allow for this.

This is an issue as when validation fails for a step then the method is called with step=None and the custom code will not be executed - in my case I was filtering ModelChoice fields based on the answers to the previous form and was losing my filters.

The example should be:

def get_form(self, step=None, data=None, files=None):
    form = super(MyWizard, self).get_form(step, data, files)

    if step is None:
        step = self.steps.current

    if step == '1':
        form.user = self.request.user
    return form

Change History (3)

comment:1 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 646a2216e97a581314c9a2598d481b9e954f2e47:

Fixed #20326 - Corrected form wizard get_form() example.

Thanks tris@ for the report.

comment:2 by Tim Graham <timograham@…>, 12 years ago

In 1c5cccedb46497daf90ff6e8e53d33680efa3b85:

[1.5.x] Fixed #20326 - Corrected form wizard get_form() example.

Thanks tris@ for the report.

Backport of 646a2216e9 from master

comment:3 by Tim Graham <timograham@…>, 12 years ago

In c97cc85b748524d2e0d66c770d485ffeded8e950:

[1.4.x] Fixed #20326 - Corrected form wizard get_form() example.

Thanks tris@ for the report.

Backport of 646a2216e9 from master

Note: See TracTickets for help on using tickets.
Back to Top