I hope this help.

def copy_and_edit():
    """
    copy_and_edit
    """
    record = db.t_disciplin(request.args[0])

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

    db.t_disziplin.insert(**vals)

    rec = db(db.t_disziplin.f_title == recname).select().first()
    rec_id = rec.id

    # redirect for edit the new record
    redirect(URL(r=request, 
f='konstanten/t_disciplin/edit/t_disciplin',args=str(rec_id)))



Am Freitag, 2. Mai 2014 14:29:26 UTC+2 schrieb LoveWeb2py:
>
> Hello,
>
> There are many times when I just want to copy the values of one record in 
> my sqlform and create a new record, but modify the content and save it. Is 
> there an easy way to do this with web2py or would I have to write the code? 
>
> Many thanks
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to