I have used a form in a view and want to update a record after submit: View: {{=SQLFORM(db.activity, record = a.id, deletable = True, hidden=dict(attr='chgact'))}} controller: if (request.vars['attr'] == 'chgact') and (request.vars['delete_this_record'] != 'on'): db(db.activity._id == request.vars['id']).update(**dict(request.vars)) I use the convention in the controller because is is described in the manual in chapter 6:
The update of record with given id can be done with: Inserting and updating from a dictionary A common issue consists of needing to insert or update records in a table where the name of the table, the field to be updated, and the value for the field are all stored in variables. For example: tablename, fieldname, and value. The insert can be done using the following syntax: db[tablename].insert(**{fieldname:value}) The update of record with given id can be done with: db(db[tablename]._id==id).update(**{fieldname:value}) Notice we used table._id instead of table.id. In this way the query works even for tables with a field of type "id" which has a name other than "id". What is going wrong? -- 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.