Hello

I m facing problem while retrieving value from text box in dynamic
form
The code is as follows:

forms.py

class ContextForm(forms.Form):
       def __init__(self, prop, *args, **kwargs):
       for i, j in enumerator(prop):
            self.fields['%s' % j] = forms.CharField(max_length = 20,
required = False, initial = 'black')

      def add_data(self):
            for name, value in self.cleaned_data.items():
                 yield(self.fields[name].label, value)

-----------------------------------------------

in views.py

if request.method=='POST':
        form1 = ContextForm(request.POST[rdict.keys()[0]],rdict)
        bound= form1.is_bound
        if form1.is_valid():
                for n in form1.add_data():
                        testlst.append(str(rdict.keys()[0]))
                return HttpResponse(str(form1))
else:
        form = ContextForm(rdict)


        template="test2.html"
        context=RequestContext(request,{'form':form})
        return render_to_response(template,context)
---------------------------------------------

test2.html

<html>
<body>

<form action="." method="POST">
{% csrf_token %}
<table>
  <tr>
    <th> Attribute Type </th>
    <th> Value </th>
   </tr>
  {% for field in form  %}
  <tr>
    <td>{{ field.label_tag }}</td>
    <td>{{ field }} {{ field.error }}</td>
    </tr>
{% endfor %}
</table>
<input type="submit" id="id_submit" value="Go"/>
</form>
</body>
</html>

------------------------------------

i am passing value to rdict = {'Color':'0'}
its sucessfully generating label value pair (i.e. Color and text box)
for me but when i am clicking on "go" button it's spliting values of
whatever inserted in text box rather than giving its value in the next
page
plz help me in this

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to