stephrdev/django-formwizard — Issue #27: Error when using conditional skipping
Author: ItsNotWorking
Created: 2011-11-02 09:49:21+00:00
State: open

I have 3 checkboxes on page 1 of my formwizard, one each representing pages 2, 3 and 4. If I write a generic conditional function to skip any of those pages if the checkbox on 1 is not ticked, and I also have "{% if wizard.steps.prev %}" or "{{ wizard.steps.step1 }}" in my template, I get the error "Caught ValueError while rendering: u'X' is not in list" where X is the index of the page that has been skipped.

Example conditional function:

def check_types(wizard):
current_step = wizard.steps.current
cleaned_data = wizard.get_cleaned_data_for_step('1') or {}
if current_step == '2' and 'option1' not in cleaned_data:
return False
if current_step == '3' and 'option2' not in cleaned_data:
return False
if current_step == '4' and 'option3' not in cleaned_data:
return False
return True