Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Error when using conditional skipping #27

Open
nickdjones opened this issue Nov 2, 2011 · 1 comment
Open

Error when using conditional skipping #27

nickdjones opened this issue Nov 2, 2011 · 1 comment

Comments

@nickdjones
Copy link

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
Copy link
Author

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.

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

No branches or pull requests

1 participant