Hi Cody,
I think you should try another approach, something simple as what you have
coded is at best wrong.

make_quiz_form_class  and _QuizForm try to get variables that are not
available. make_quiz_form_class doesn't take any arguments as per your
definition but you are supplying it with request.POST which is
dictionaryish.

Sent from my Windows Phone
------------------------------
From: Cody Scott
Sent: 4/22/2013 9:22 PM
To: django-users@googlegroups.com
Subject: How to create a Dynamic Hierarchical Form

I am trying to create a form where you select product(s) and technology(s)
and based on your selection different modules are available for selection.

forms.py

def make_quiz_form_class():
    #Listing available options
    products = [(i, _(i)) for i in Product.objects.all()]
    technologies    = [(i, _(i)) for i in Technology.objects.all()]
    modules = [(i, _(i)) for i in
Module.objects.filter(product=selected_products,
technologies=selected_technologies)]

    class _QuizForm(forms.Form):
        selected_products = forms.ChoiceField(choices = products,
widget=forms.RadioSelect())
        selected_technologies = forms.ChoiceField(choices =
technologies, widget=forms.RadioSelect())
        selected_modules = forms.ChoiceField(choices = modules,
widget=forms.RadioSelect())

    return _QuizForm

views.py

form_class = make_quiz_form_class()
form = form_class(request.POST)

The problem is selected_products and selected_technologies are not defined
for modules

-- 
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to