Little_Grungy
unread,Feb 26, 2008, 3:57:20 PM2/26/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hi
I have the following form for a list of languages:
class Languages(forms.Form):
language_list = (('python', 'python'), ('c', 'c'), ('java', 'java'),
('c++', 'c++'), ('php', 'php'), ('perl',
'perl'))
languages = forms.MultipleChoiceField(label='Languages',
required=True,
widget=forms.CheckboxSelectMultiple,
choices=language_list)
When I render the form in my template as follows:
<table>
{{ form }}
</table>
The HTML is generated as follows:
<tr>
<th>
<label for="id_languages_0">
Languages:
</label>
</th>
<td>
<ul>
<li>
<label>
<input type="checkbox" name="languages" value="python"
id="id_languages_0" />
python
</label>
</li>
<li>
<label>
<input type="checkbox" name="languages" value="c"
id="id_languages_1" />
c
</label>
</li>
<li>
<label>
<input type="checkbox" name="languages" value="java"
id="id_languages_2" />
java
</label>
</li>
<li>
<label>
<input type="checkbox" name="languages" value="c++"
id="id_languages_3" />
c++
</label>
</li>
<li>
<label>
<input type="checkbox" name="languages" value="php"
id="id_languages_4" />
php
</label>
</li>
<li>
<label>
<input type="checkbox" name="languages" value="perl"
id="id_languages_5" />
perl
</label>
</li>
</ul>
</td>
</tr>
Is there any way to have the checkboxes (and also the same for radio
buttons) rendered horizontally, ideally within one cell in a table? I
cannot find a way to do this.
Thank you