On Wed, Feb 18, 2009 at 8:52 AM, koranthala <koranth...@gmail.com> wrote:
> > Hi, > I am unable to extract values from form fields inside templates. > For example: > I have mutiple text fields in which one field says whether the > second field is X or not and the second field containing the actual > data. (These are initial values which I send from server to client) > Now, in case it is of type X, I want to do something in the > template. > > I tried to do it as follows: > In template: > {% ifequal forms.typename "username" %} > {{ form.name }} <img src={{form.img}}/> > {% else %} > {{ form.text }} > > Django Code: > class frm(forms.Form): > typename = forms.CharField(widget=forms.TextInput()) > text = forms.CharField(widget=forms.TextInput()) > name = forms.CharField(widget=forms.TextInput()) > img = forms.CharField(widget=forms.TextInput()) > > I was unable to do it via forms, since I cannot extract the data. > so I have to have another variable which sends the same data - which > is against the DRY principle. > > Is it possible to extract the text data from the form widgets? > I don't have time to verify, but I believe: {% ifequal forms.typename.data "username" %} is what you want. Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---