#20326 closed Cleanup/optimization (fixed)
Documentation for form wizard -> get_form()
Reported by: | 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
Note:
See TracTickets
for help on using tickets.
In 646a2216e97a581314c9a2598d481b9e954f2e47: