A simple way: def edit(): fields = ['setting1'] form = SQLFORM(mytable, request.args(0), fields=fields) if form.accept(): # do stuff
On Sep 23, 5:14 pm, Alex <mrauc...@gmail.com> wrote: > thanks for the response! I already thought about using dbio=False > parameter, with the update_record method this should now be quite > easy. > > explanation why it's important for me: in my scenario the auth_user > table has many additional fields (address, bank account information, > etc.), all these settings can only be changed by an admin user. only > the password can be modified by the user itself. If both the admin and > the user edit the same record at a time, the last one who saves it > would overwrite the previous changes. If I only update the fields > which are shown in the form then both users cannot overwrite the > changes of each other. I'm also performing optimistic locking (with a > version nr.) but in this case it is not necessary because both users > modify different fields. > > On 23 Sep., 22:13, DenesL <denes1...@yahoo.ca> wrote: > > > > > It is not a bug. Quoting the book: > > When a Field is marked with writable=False, the field is not shown in > > create forms, and it is shown readonly in update forms. If a field is > > marked as writable=False and readable=False, then the field is not > > shown at all, not even in update forms. > > > This has nothing to do with the auto-(update, insert or delete) > > operations performed by form.accepts > > > To update only the setting1 field you can do: > > > def edit1(): > > id = request.args(0) > > db.mytable.setting2.readable = db.mytable.setting2.writable = > > False > > row = db.mytable(id) > > form=SQLFORM(db.mytable, row) > > if form.accepts(request.vars, formname='mytable_form', > > dbio=False): > > row.update_record(**form.vars) > > logger.debug(db._lastsql) > > return dict(form=form) > > > as explained > > in:http://web2py.com/book/default/chapter/07#SQLFORM-without-database-IO > > > but it really makes no difference, except for some IO, the resulting > > database record will be identical in both cases, so why bother?.