198 type = 'checkbox' |
198 type = 'checkbox' |
199 |
199 |
200 def render(self, form, field): |
200 def render(self, form, field): |
201 name, curvalues, attrs = self._render_attrs(form, field) |
201 name, curvalues, attrs = self._render_attrs(form, field) |
202 domid = attrs.pop('id', None) |
202 domid = attrs.pop('id', None) |
|
203 sep = attrs.get('separator', u'<br/>') |
203 options = [] |
204 options = [] |
204 for i, (label, value) in enumerate(field.vocabulary(form)): |
205 for i, (label, value) in enumerate(field.vocabulary(form)): |
205 iattrs = attrs.copy() |
206 iattrs = attrs.copy() |
206 if i == 0 and domid is not None: |
207 if i == 0 and domid is not None: |
207 iattrs['id'] = domid |
208 iattrs['id'] = domid |
208 if value in curvalues: |
209 if value in curvalues: |
209 iattrs['checked'] = u'checked' |
210 iattrs['checked'] = u'checked' |
210 tag = tags.input(name=name, type=self.type, value=value, **iattrs) |
211 tag = tags.input(name=name, type=self.type, value=value, **iattrs) |
211 options.append(tag + label + '<br/>') |
212 options.append(tag + label + sep) |
212 return '\n'.join(options) |
213 return '\n'.join(options) |
213 |
214 |
214 |
215 |
215 class Radio(CheckBox): |
216 class Radio(CheckBox): |
216 """<input type='radio'>, for field having a specific vocabulary. One |
217 """<input type='radio'>, for field having a specific vocabulary. One |