You can also use with crud.create() crud.settings.create_onvalidation=lambda form: form.vars.update(field2=form.vars.field1)
and crud.update() crud.settings.update_onvalidation=lambda form: form.vars.update(field2=form.vars.field1) or with SQLFORM from.accept(...., onvalidation=lambda form: form.vars.update(field2=form.vars.field1)): On Feb 6, 2:45 am, Adi <aditya.sa...@gmail.com> wrote: > I searched for "compute" in the scribd document on the website and > didn't find this. It should be included as it is quite helpful. > > On Feb 5, 11:42 pm, Thadeus Burgess <thade...@thadeusb.com> wrote: > > > Is this not in the book or did I miss it? > > > -Thadeus > > > On Fri, Feb 5, 2010 at 5:34 AM, Adi <aditya.sa...@gmail.com> wrote: > > > Awesome, works as expected. > > > > Only change is that the request variables were strings and had to be > > > converted into respective data types. Thanks a lot. > > > > On Feb 5, 4:19 pm, hywang <why00...@163.com> wrote: > > >> something like this > > >> def _compute(): > > >> return request.vars.in_time + request.vars.duration## > > > >> db.define_table('mytable', Field('in_time','datetime'), > > >> Field('duration', 'integer'), Field('end_time','datetime', compute = > > >> _compute)) > > > >> On Feb 5, 6:51 pm, Adi <aditya.sa...@gmail.com> wrote: > > > >> > Hi, > > > >> > I have a table with 3 fields: > > > >> > db.define_table('mytable', Field('in_time','datetime'), > > >> > Field('duration', 'integer'), Field('end_time','datetime')) > > > >> > The user enters in_time and duration (in hours) in SQLFORM, but now I > > >> > want to calculate and store end_time using > > >> > end_time = in_time + timeinterval(hours = duration). > > > >> > I'm not able to achieve this. How do I refer to a record's other > > >> > fields to specify default value of a field? > > > >> > Thanks. > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "web2py-users" group. > > > To post to this group, send email to web...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > web2py+unsubscr...@googlegroups.com. > > > For more options, visit this group > > > athttp://groups.google.com/group/web2py?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.