Thanks to both of the responders. The reference and example have answered my question. (and introduced some concepts I was unfamiliar with) - Tom
On Dec 3, 9:30 pm, "mr.freeze" <[email protected]> wrote: > Here is an example: > > Model > ----- > db.define_table('things',Field('name',requires=IS_NOT_EMPTY()), > Field('age','integer'),Field('weight','double')) > db.things.id.represent = lambda v: A(v,_href=URL(vars=dict(dupe=v)), > _onclick='return confirm("Copy > %s?")' % v) > > Controller > ---------- > def index(): > form = SQLFORM(db.things) > if form.accepts(request.vars,session): > response.flash = 'Added a thing' > if request.vars.dupe: > record = db.things(request.vars.dupe) > vals = {} > for k,v in record.items(): > if k in db.things.fields: > vals[k] = v > db.things.insert(**vals) > things = db(db.things.id>0).select() > return dict(form=form,things=things) > > On Dec 3, 6:12 pm, tomt <[email protected]> wrote: > > > Hi, > > > I've started to write a simple application to learn web2py. I am using > > SQLFORM to insert, modify and delete records. So far everything is > > working as planned. > > > I would like to give the user the ability add a new record as a copy > > of an existing one. The idea is that the user would view an existing > > record, modify a couple fields, and select 'copy' which result in > > adding a new record. > > > I assume that this requires additional code, and I was hoping that > > someone would suggest an example, or let me know if SQLFORM can do > > this automatically. > > > Thanks in advance, > > > - Tom > >

