Your Ad Here

Wednesday, January 11, 2012

Managing a long and complex form

Hello,

I have a huge form, based off a model with dozens of fields. Most of
them are easily rendered with:

<div class="form-item">
{{ field.label_tag }}
{{ field }}
</div>

or something to the effect.

Some others require custom html, for instance a "location" field that
couples a textbox with a google map, or a "area" field represented as
a table of textboxes associated to different units where you enter a
quantity in any of them and it auto-updates the value of all others.

Those dozens of fields are grouped in categories, so I would naturally
want to display them grouped in fieldsets.

My question is ¿what would be an elegant solution to rendering such a
form? Right now I have a huge template where everything is rendered
"by hand":

<div class="form-item">
{{ field1.label_tag }}
{{ field1 }}
</div>

<div class="form-item location">
{{ special_field.label_tag }}
{{ field }}
<div class="map"></div>
</div>

<div class="form-item">
{{ field2.label_tag }}
{{ field2 }}
</div>

<div class="form-item">
{{ field3.label_tag }}
{{ field2 }}
</div>

etc., which is ugly and is driving me crazy.

Thanks in advance!

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

0 comments:

Post a Comment