The most elegant way I've seen specialized form rendering handled was
the use of template tags and filters.  The django uni-form project is
a good example.  By using the filter and template tags you gain full
access to all the form elements, and can do easy manipulation in
python, but leave the rendering and html to a template.

if you wanted your multiplecheckboxes field to render in three columns
you could write a filter (formfield_columns for example) that took the
formfield as parameter, and the number of columns and returned the
appropriate breakdown with the right info that might be used something
like this:

{% for row in myform.field|formfield_columns:3 %}
<tr>
  {% for cb in row %}
     <td>
       <input id= "{{cb.id}}" type="checkbox" name="{{cb.name}}}"
value="cb.value" {% if cb.checked %}checked{% endif%}/>   <label
for="{{cb.id}}">{{cb.label}}</label>
    </td>
  {% endfor %}
</tr>
{% endfor %}

where your filter converted the field into a list of rows, with each
checkbox representating a dict populated with values (keys checked,
name, id, label) from the form field.

you could also make a filter that does a single value in your
multiplecheckbox field

{{form.field|formcheckbox_value:"myvalue"}}

-- 
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