Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form reset does not work for NamedUrlWizardView #202

Open
danielsjf opened this issue Oct 25, 2021 · 1 comment
Open

Form reset does not work for NamedUrlWizardView #202

danielsjf opened this issue Oct 25, 2021 · 1 comment

Comments

@danielsjf
Copy link

From the source code I understand that it is possible to reset formtools via
See:

if 'reset' in self.request.GET:

This would work for urls like https://[...]formtools-url?reset

Unfortunately this doesn't work for named wizards since the step_url is not None. Setting it to None typically does not work with the url parameters https://[...]formtools-url/<step>/

I think adding the following code could solve this.

elif step_url == 'reset':
    self.storage.reset()
    self.storage.current_step = self.steps.first

After which urls like https://[...]formtools-url/reset/ could reset the form.

@pfouque
Copy link
Member

pfouque commented Feb 14, 2024

As per the documentation, the wizard needs to be declared as 2 separate URLs, with and without the step parameter

urlpatterns = [
    re_path(r'^contact/(?P<step>.+)/$', contact_wizard, name='contact_step'),
    path('contact/', contact_wizard, name='contact'),
]

It makes it possible to start/continue the wizard, and reset parameter is working ONLY if the step is not defined.
What makes sense, calling "reset" on a specific step should reset only this step, not the whole wizard! 😅

But I agree (because I did it), that handling a specific step_name (similar to the ‘done‘ one) to reset would be handy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants