The easiest way to do that is rely on web2py model -> form transformation 
and use a validator (instead of the custom form).

model
------------------------------------------
MY_OPTIONS = ["a","b","c"]
db.define_table("my_table",
    db.Field("my_options", "list:string", default=MY_OPTIONS))

db.my_table.my_options.widget = SQLFORM.widgets.checkboxes.widget
db.my_table.my_options.requires = [IS_IN_SET(MY_OPTIONS, multiple=True), 
IS_NOT_EMPTY()]

controller
------------------------------------------
def my_function():
    if len(request.args):
        form=SQLFORM(db.my_table, request.args[0])
    else:
        form=SQLFORM(db.my_table)

    if form.accepts(request.vars):
        redirect(URL(r=request, f='my_next_function', args=[form.vars.id]))

    return {"form":form}

Reply via email to