Tuesday, December 28, 2010

CheckboxSelectMultiple HTML

I have a form:
class AddUserForm(forms.Form):
    checkboxes = forms.MultipleChoiceField(required=True,
                                           widget=CheckboxSelectMultiple(),
                                           choices=check_groups())

In the template I put:

  {% for choice_id, choice_label in form.fields.checkboxes.choices %}
        <div class="groups">
        <input type="checkbox" name="group" value ={{ choice_label }}  /><br />
        <!--value={{ choice_label }}  <br />-->
        </div>
    {% endfor %}

Which displays a list of the correct number of checkboxes but with no text.  I use the commented line to render choice_label as text, all the values appear.

How do I get the value of choice_label to appear next to the checkbox?

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

No comments:

Post a Comment