Hi. I'm new with Web2py and have a question.
I have a table with a boolean, and the user can add or remove
checkboxes. The table is updated with the new value, but I need my
form re-populated so that it shows the changes.
My code is the following:
def sucursales():
records=db(db.auth_sucursal.user_id==str(auth.user_id)).select()
input_holder=[]
for record in records:
input_holder+=[LABEL("Sucursal: " + str(record['sucursal']))]
input_holder
+=[INPUT(_type='checkbox',_name="check-"+str(record['id']),value=record['mostrar']),BR()]
input_holder+=[INPUT(_type='submit')]
form=FORM(input_holder)
if form.accepts(request.vars,session):
for item in form.vars.keys():
db(db.auth_sucursal.id==item[-1:]).update(mostrar=form.vars[item] or
0)
# Here I should update the changed checkbox!!!
response.flash = 'Sucursales guardadas'
elif form.errors:
response.flash = 'Ha habido un error. Por favor reintente mas
tarde'
return dict(form=form)
How can I update the form after I created it?
Thanks a lot!