I can do something like this:

fields = [Field('myfield', type = integer, default =
db((db.mytable.id==id).select(db.mytable.myfield).first()]
form=SQLFORM.factory( *fields)

if form.accepts(request.vars, session):
    db(db.mytable.id==id).update(myfield=form.vars[entry])

 form.custom.widget['myfield']['value'] =
db((db.mytable.id==id).select(db.mytable.myfield).first() #updated
value
 form.custom.widget['myfield']._postprocessing()

intention:
I can make a custom form that updates several databases/field
combinations, but I want to instantly show these changes in the form
and thus have to update the form values. Otherwise I will continually
alternate the changes between database and form.

this works as intended.

BUT:

If I want to do the same thing with "boolean" datatypes (and
checkboxes in the form) this does not work.

I tried:

 form.custom.widget['myfield']['value'] =
db((db.mytable.id==id).select(db.mytable.myfield).first() #updated
value
 form.custom.widget['myfield']._postprocessing()

 form.custom.widget['myfield']['value'] = True
 form.custom.widget['myfield']._postprocessing()

 form.custom.widget['myfield']['checkbox'] = "checked"
 form.custom.widget['myfield']._postprocessing()

and such, but It never shows and I get the "alternating" behaviour
(either form or database is updated but never both at the same time).

Question: How do I change the form.custom.widget values of checkbox
widgets ?

Reply via email to