I have a working django formwizard which when I hit the previous button doesn't validate the current input.
I've tried variations on
<input name="wizard_goto_step" class="btn btn-primary btn-large" type="submit" value="prev"/>
and
<button class="btn btn-info btn-large"
name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">
{% trans "prev step" %}
</button>
but neither of these seems to do what I want to do.
One (arguably elegant) way would be to use a different POST variable than
wizard_goto_step
, and then overrideWizardView.get_next_step()
:Then, use
name="wizard_next_step"
on the previous-step button/link. This approach both has the advantage that the old behavior remains available should you need it, and that you're not re-implementingWizardView.post()
.If you want it to validate and save the data on the current form before stepping back to a previous form, you need to override the
post()
method in your subclass ofSessionWizardView
. The methods you're looking for areself.storage.set_step_data()
andself.storage.set_step_files()
to save the current form data.A rough example: