# HG changeset patch # User Florent # Date 1242317565 -7200 # Node ID 3384264d25cca9577954bbfcb0a98fe8558bf74d # Parent 183acfaa3cde552f8a0c4a80f1f0afc3974f155f fix CheckBox multiple dom id and refactor with Radio diff -r 183acfaa3cde -r 3384264d25cc web/formwidgets.py --- a/web/formwidgets.py Thu May 14 08:35:19 2009 +0200 +++ b/web/formwidgets.py Thu May 14 18:12:45 2009 +0200 @@ -199,26 +199,6 @@ def render(self, form, field): name, curvalues, attrs = self._render_attrs(form, field) - options = [] - for label, value in field.vocabulary(form): - if value in curvalues: - tag = tags.input(name=name, value=value, type=self.type, - checked='checked', **attrs) - else: - tag = tags.input(name=name, value=value, type=self.type, - **attrs) - options.append(tag + label) - return '
\n'.join(options) - - -class Radio(Input): - """, for field having a specific vocabulary. One - input will be generated for each possible value. - """ - type = 'radio' - - def render(self, form, field): - name, curvalues, attrs = self._render_attrs(form, field) domid = attrs.pop('id', None) options = [] for i, (label, value) in enumerate(field.vocabulary(form)): @@ -232,6 +212,12 @@ return '\n'.join(options) +class Radio(CheckBox): + """, for field having a specific vocabulary. One + input will be generated for each possible value. + """ + type = 'radio' + # javascript widgets ########################################################### class DateTimePicker(TextInput):