From c69fdb0e5b0efa6bd8677ca4a6f5a6766ede3d37 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 6 Oct 2020 09:50:18 +0200 Subject: [PATCH] conditional forms finally working --- input/views.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/input/views.py b/input/views.py index 0d6b536..e6799d9 100644 --- a/input/views.py +++ b/input/views.py @@ -42,15 +42,23 @@ class ExternView(CookieWizardView): # return self.get_form_step_data(form) def get_form(self, step=None, data=None, files=None): - if step: - print ("get_form() step " + step) + if step is None: + step = self.steps.current + print ("get_form() step " + step) + + # prev_data = self.get_cleaned_data_for_step(self.get_prev_step( + # self.steps.current)) + # print (data) + if step == '1': - print('iiiooopppp') - data = self.get_cleaned_data_for_step('0') - print (data) - if data.get('choice') == 'IFG': + prev_data = self.get_cleaned_data_for_step('0') + if prev_data.get('choice') == 'IFG': print ('IFG detected!') - form = super().get_form(step, data, files) + form = IFGForm(data) + else: + form = LibraryForm(data) + else: + form = super().get_form(step, data, files) return form def done(self, form_list, **kwargs):