I am trying to make a user editor and running into trouble. I have the
standard auth_user table, and I also have an auth_user_extended table that
stores a bunch of other information, using auth_user as the reference
between the two tables. I set my controller up like this:
def update():
id = request.vars.id or request.args(0) or error()
row = db((db.auth_user.id==db.auth_user_extended.id) &
(db.auth_user.id==id)).select().first()
if row is None:
error()
form = SQLFORM.factory(db.auth_user, db.auth_user_extended
hidden: {'id': id}
)
form.vars.id = id
form.vars.auth_user = id
form.vars.username = row.auth_user.username
form.vars.first_name = row.auth_user.first_name
... etc ...
if form.accepts(request.vars, session, keepvalues=True):
# do the database update manually
However, my problem is that when submitting the form for an update, it fails
validation on username because "value already in database". Am I doing
something wrong or does SQLFORM.factory not support updates? Thanks.