Thursday, May 3, 2012

Re: Access specific ModelForm field option within array of ModelForms for use with .js

You're right! 

Thank you.

I have a custom template filter in the app to format the radio options a certain way and I can just add this in to pick out the ones needing the additional onChange.

JD


On Tuesday, May 1, 2012 9:27:01 PM UTC-6, jondykeman wrote:
Hello, 

I have the following situation:

I am rendering an array of ModelForms to my template. ie. formArray = [<ModelForm1>, <ModelForm2>, <ModelForm3>]

In the template I display the forms with the following:

{% for form in formArray %}
<div class="clearfix">
{{ form }}
</div>
{% endfor %}

Previously I have accessed certain ModelForms using {% if forloop.counter == # %} to add some customization.

However, now I would like more detailed control of certain field tags within a given ModelForm. ie. ModelForm2 is a RadioSelect, and I would like to add an onChange="some function" to one of the Radio Buttons within this ModelForm. 

Is there a way to access this specific field in my implementation directly? Or, through the use of a custom template filter?

To give the larger picture my goal is to have an "Other" RadioButton that when selected shows a Other text input using javascript, but while using ModelForms.

As such, if there is an entirely different way to going about this I would love to hear it. 

Any help would be greatly appreciated!


JD



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/R26wVKtkf1YJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate