Created
January 9, 2012 10:15
-
-
Save katjakarhu/1582320 to your computer and use it in GitHub Desktop.
Django: render RadioSelect as table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RadioTableRenderer(RadioSelect.renderer): | |
| def __iter__(self): | |
| choicelist = "" | |
| inputlist = "" | |
| for i, choice in enumerate(self.choices): | |
| id = '%s' % (self.attrs['id'] if 'id' in self.attrs else '') | |
| #label_for = ' for="%s"' % id if id else '' | |
| choicelist = choicelist +"<th>"+choice[1]+"</th>" | |
| inputlist = inputlist + '<td><input type="radio" id="%s" value="%s" name="%s"/></td>\n' % (id, choice[0], self.name) | |
| yield '<table><thead>%s</thead>\n<tr>%s</tr>\n</table>' % ( | |
| choicelist, inputlist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment