ocgstyles
unread,Aug 18, 2008, 4:10:50 PM8/18/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
I'm experiencing some strange behavior with the Form Wizard. During
testing, sometimes I'll get to the last step, click Finish, and I'll
get another form with no fields and finish button turns back into a
next button.
Its set up like this:
# urls.py
(r'^application/$', MyWizard([Appl1, Appl2, DummyForm, DummyForm])),
I use DummyForms (class DummyForm(forms.Form): pass) as a place holder
because I know I will have 4 steps. During the process_step function,
I want to insert the correct forms. The form that displays for step3,
depends on a value selected in step2. A value in step3, determines
which field gets inserted for step 4. I see some examples out there
where people use form_list.append(NewForm) to add steps. I chose not
to do this because I am display an indicator that states which step
you are on; I don't want the total number of steps to change.
So the process_step logic looks like this:
# forms.py
def process_step(self, request, form, step):
# cleaned_data at this point apparently contains a unicode string
value, rather than a python data type - annoying.
if form.__class__.__name__ == 'Appl2' and
form.__dict__.has_key('cleaned_data'):
if form.cleaned_data['test_value_1'] == 'True':
self.form_list[2] = Appl3_yes
else
self.form_list[2] = Appl3_no
if form.__class__.__name__ == 'Appl3' and
form.__dict__.has_key('cleaned_data'):
if form.cleaned_data['test_value_2'] == 'True':
self.form_list[3] = Appl4_yes
else
self.form_list[3] = Appl4_no
First off, am I using the "process_step" function properly? In my
case, does the fact that this function gets called after each submit
for every completed step? For example:
Step 0
Step 0, 1
Step 0, 1, 2
Step 0, 1, 2, 3
I have a feeling I'm just screwing up something elementary, because I
have another form that works just like this one, only difference being
that I only do 1 form substitution, rather than 2.
Any ideas?
Keith