Replace
Field('modified_by',db.auth_user, default=me),
Field
('modified_on','datetime',default=request.now,writable=False))
with
Field('modified_by',db.auth_user, update=me),
Field
('modified_on','datetime',update=request.now,writable=False))
then you do not need update_record and your can use crud
On Jan 8, 7:52 am, Miguel Lopes <[email protected]> wrote:
> In many models I have the following field definitions:
>
> ...
> Field('created_by',db.auth_user,default=me,writable=False),
> Field('created_on','datetime',default=request.now,writable=False),
> Field('modified_by',db.auth_user, default=me),
> Field('modified_on','datetime',default=request.now,writable=False))
>
> When creating forms based on these tables, I've been using SQLFORM in
> order to update the modified_on and the modified_by columns:
>
> if form.accepts(request.vars, session, keepvalues=True):
> opportunity.update_record(modified_by=1)
> opportunity.update_record(modified_on=request.now)
> response.flash='record updated'
>
> This is the only reason for using SQLFORM on these controllers and
> I've been wondering if there is some pattern to achieve the same using
> crud. That is how could the modified_by and the modified_on fields be
> updated
>
> Txs,
> Miguel
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.