ok I used this in the end :)

links = [lambda row: A('Copy',_href=URL("formdb","copy_profile",args=[row.id]))]


@auth.requires_login()
def copy_profile():

    record = db.lparprofile(request.args[0])

    vals = {}
    for k,v in record.items():
        if k in db.lparprofile.fields:
            if k == 'lparname':
                v = v + "_copy"
recname = str(v) # Needed to redirect the page to the right record
            if k != 'id':
                vals[k] = v

    db.lparprofile.insert(**vals)
    rec = db(db.lparprofile.lparname == recname).select().first()
    rec_id = rec.id
    redirect(URL(r=request, f='manage_profile',args=str(rec_id)))

    return



Problem solved :-)

On 04/12/2012 03:19 PM, Mike Veltman wrote:
On 04/12/2012 01:08 PM, Mike Veltman wrote:
Well I would like to have besides edit delete etc in my SQLFORM.grid also a copy option that copies the record and then gives me the edit so I can modify it.

Anyone a idea how to do that ?

Mike

Aha I have to use links (RTFM)
Does anybody have a example of the link and the called function for me ?



Reply via email to