django-formwizard icon indicating copy to clipboard operation
django-formwizard copied to clipboard

Error when using conditional skipping

Open nickdjones opened this issue 13 years ago • 1 comments

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

nickdjones avatar Nov 02 '11 09:11 nickdjones

OK ignoring the fact I've done this completely wrong and haven't selected the field from the cleaned_data (should be cleaned_data.get('options', {}) on each line), is it possible to determine steps from within a conditional function? If I use wizard.steps.next() it goes into a recursive loop.

nickdjones avatar Nov 02 '11 10:11 nickdjones