-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import zope.schema | ||
import zope.schema.interfaces | ||
from zope.i18n import translate | ||
from zope.pagetemplate.interfaces import IPageTemplate | ||
|
||
from z3c.form import interfaces, util | ||
from z3c.form.widget import SequenceWidget, FieldWidget | ||
|
@@ -39,6 +40,17 @@ class RadioWidget(widget.HTMLInputWidget, SequenceWidget): | |
def isChecked(self, term): | ||
return term.token in self.value | ||
|
||
def renderForValue(self, value): | ||
term = self.terms.getTermByToken(value) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
strichter
Contributor
|
||
checked = self.isChecked(term) | ||
id = '%s-%i' % (self.id, list(self.terms).index(term)) | ||
item = {'id': id, 'name': self.name, 'value': term.token, | ||
'checked': checked} | ||
template = zope.component.getMultiAdapter( | ||
(self.context, self.request, self.form, self.field, self), | ||
IPageTemplate, name=self.mode + '_single') | ||
return template(self, item) | ||
|
||
def update(self): | ||
"""See z3c.form.interfaces.IWidget.""" | ||
super(RadioWidget, self).update() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml" | ||
xmlns:tal="http://xml.zope.org/namespaces/tal" | ||
tal:define="item python:args[0]" | ||
tal:omit-tag=""> | ||
<input id="" name="" class="" alt="" title="" | ||
tabindex="" disabled="" readonly="" accesskey="" value="" | ||
checked="" type="radio" | ||
tal:define="checked item/checked" | ||
tal:attributes="id item/id; | ||
name item/name; | ||
class view/klass; | ||
value item/value; | ||
style view/style; | ||
title view/title; | ||
lang view/lang; | ||
onclick view/onclick; | ||
ondblclick view/ondblclick; | ||
onmousedown view/onmousedown; | ||
onmouseup view/onmouseup; | ||
onmouseover view/onmouseover; | ||
onmousemove view/onmousemove; | ||
onmouseout view/onmouseout; | ||
onkeypress view/onkeypress; | ||
onkeydown view/onkeydown; | ||
onkeyup view/onkeyup; | ||
disabled view/disabled; | ||
tabindex view/tabindex; | ||
onfocus view/onfocus; | ||
onblur view/onblur; | ||
onchange view/onchange; | ||
readonly view/readonly; | ||
alt view/alt; | ||
accesskey view/accesskey; | ||
onselect view/onselect; | ||
checked python: checked and 'checked' or None" | ||
/> | ||
</html> |
There seems to be some confusion between value and token here? Maybe it's fine ("value" in the sense of <input type="checkbox" value=...), but there's space for confusion, so the docs should be explicit.