I think is not working. Anybody is using it with multiple=true?.
I make a fix.
def widget_checkbox(self, field, value, **attributes):
"""
generates a TABLE tag, including INPUT checkboxes (multiple allowed)
see also: :meth:`FormWidget.widget`
"""
from gluon.sqlhtml import OptionsWidget
# was values = re.compile('[\w\-:]+').findall(str(value))
values = not isinstance(value,(list,tuple)) and [value] or value
attr = OptionsWidget._attributes(field, {}, **attributes)
requires = field.requires
if not isinstance(requires, (list, tuple)):
requires = [requires]
if requires:
if hasattr(requires[0], 'options'):
options = requires[0].options()
else:
raise SyntaxError, 'widget cannot determine options of %s' \
% field
options = [(k, v) for k, v in options if k!='']
opts = []
cols = attributes.get('cols',1)
totals = len(options)
mods = totals%cols
rows = totals/cols
if mods:
rows += 1
for r_index in range(rows):
tds = []
for k, v in options[r_index*cols:(r_index+1)*cols]:
#print "k: %s"%k
#print "v: %s"%v
#print "values: %s"%values
if int(k) in values:
r_value = k
else:
r_value = []
#print "r_value: %s"%r_value
tds.append(TD(INPUT(_type='checkbox', _name=field.name,
requires=attr.get('requires',None),
hideerror=True, _value=k,
value=r_value
), v))
opts.append(TR(tds))
if opts:
opts[-1][0][0]['hideerror'] = False
return TABLE(*opts, **attr)
--
Pablo Martín Mulone ([email protected])
http://www.tecnodoc.com.ar/
My blog: http://martin.tecnodoc.com.ar
Expert4Solution Profile:
http://www.experts4solutions.com/e4s/default/expert/6