keep values in forms with keepvalues

[edit|delete]

Sometime you want an insert form that, upon submission and after the insert, retains the preceding values to help the user insert a new record. This can be done:

db=SQLDB('sqlite://db.db')
db.define_table('user', SQLField('name','string'))

And in controller

def test():    
    form=SQLFORM(db.user)
    if form.accepts(request.vars,session,keepvalues=True):
        response.flash="record inserted"
    return dict(form=form)

Notice the keepvalues=True argument of the accepts method.



Post a comment