Re: Dynamically appending a step to FormWizard

2008-10-02 Thread Rock

I cannot show you the entire code since the company lawyers have not
had time to allow me to release this snippet, but I did get this
working. However it was not easy and required some interaction with
the guys who created FormWizard.

My approach was to create a DummyForm which I put in the second slot
of the form_list. I also had a dictionary of possible replacement
forms which were chosen via a selection on the first form.
The critical bit of processing looks like this:

def process_step( self, request, form, step ):
if step == 0:
if form.is_valid():
selection = form.cleaned_data["selection"]
self.extra_context["selection"] = selection
if self.form_list[1] != self.form_dict[selection]:
self.form_list[1] = self.form_dict[selection]

The is_valid call forces a reclean of the first form's data each time,
but is required since you can't reliably save state data during this
process. (Also don't freak out that step == 0 occurs with each
iteration through your wizard as you go to subsequent steps.)

There may be more challenges after you get across this bridge, so
please post a follow up on how this works out for you.

Rock


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamically appending a step to FormWizard

2008-10-02 Thread Rock

I can't show you the code yet since I haven't got permission to post
it cleared from my company, but I got this working. (It was not easy
and req
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Dynamically appending a step to FormWizard

2008-09-30 Thread Jeroen

Hi All,

I'm adding a step to FormWizard based on user input from the previous
(first) step:

  def process_step(self, request, form, step):
if step == 0:
  self.form_list.append(get_form2(form.cleaned_data['mode']))

Above works, a second (and final) form is created based on the value
of mode. However, after submitting this  last form I get an error
"Step 1 does not exist". The dynamically added form disappears from
form_list.

Anyone have any ideas on how this should work?

Thanks,
Jeroen


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---