In your example, list_chart is not a list of strings, it is a list of tuples.
In my code, hostnames is just a list of hostnames. e.g. ('hostname1.example.com','hostname2.example.com') I assume that you are trying to make the checkboxes default to true. For me, they defaulted to being checked. On Monday, December 12, 2016 at 3:50:58 PM UTC-6, 黄祥 wrote: > > trying the tricks but got error when the checkbox is empty (1 or all > checkbox is empty, when all checkbox is on its work) : > *e.g.* > def test_form(): > redirect_url = 'test' > > list_chart = [(True, 'line'), > (True, 'pie'), > (True, 'bar') ] > > form = SQLFORM.factory( > Field('chart', 'list:string', > default = list_chart, > widget = SQLFORM.widgets.checkboxes.widget, > requires = [IS_IN_SET(list_chart, multiple = True) ] ) ) > if form.process().accepted: > chart = form.vars.chart > line = form.vars.line[0] > pie = form.vars.pie[1] > bar = form.vars.bar[2] > > response.new_window = URL(redirect_url, args = [chart] ) > #response.new_window = URL(redirect_url, args = [line, pie, bar] ) > elif form.errors: > response.flash = T('Form has errors') > return dict(form = form) > > *Traceback error:* > line = form.vars.chart[0] > IndexError: list index out of range > > any idea how to face it using web2py way? > > thanks and best regards, > stifan > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.