﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11726	FormWizard sanity check on step number performed before dynamic steps can be inserted	Eric Friesen <ericfriesen@…>	esper256	"If you are making a FormWizard to have dynamically created steps, where the number of steps depends on the form input of the previous steps, you run into a problem with the sanity check inside FormWizard's {{{__call__}}} method.

{{{
        # Sanity check.
        if current_step >= self.num_steps():
            raise Http404('Step %s does not exist' % current_step)

        # For each previous step, verify the hash and process.
        # TODO: Move ""hash_%d"" to a method to make it configurable.
        for i in range(current_step):
            form = self.get_form(i, request.POST)
            if request.POST.get(""hash_%d"" % i, '') != self.security_hash(request, form):
                return self.render_hash_failure(request, i)
            self.process_step(request, form, i)
}}}

Your cleaned_data to determine if you need to add more steps isn't available until process_step is called on the earlier steps. However it will never get that far because the current step will be over the number of steps the FormWizard was initially constructed with (in the urls.py for example).

Currently I have worked around this in my code by constructing FormWizard with enough dummy steps that are removed and replaced with real ones just so the formcount is always greater than the dynamic count will ever be in the very beginning.

My proposed solution would be to do a sanity check each iteration of the forloop ensuring that there's at least enough forms to process the next one."	Bug	closed	contrib.formtools	dev	Normal	fixed	FormWizard	michal.modzelewski@…	Ready for checkin	1	0	0	0	0	0
