What do you mean? You can redirect (A('Link', _href=URL(controler, function, vars=dict(pass_your_record_vars_here=record_vars1, ...))) to a function that do what I wrote above... Just pass record value throught vars then request.vars.field1 request.vars.field2 and assign .default= request.vars.field1
Richard On Fri, May 2, 2014 at 9:33 AM, LoveWeb2py <atayloru...@gmail.com> wrote: > Richard, > > How do I assign this to a button though? > > > On Friday, May 2, 2014 9:30:21 AM UTC-4, Richard wrote: > >> keepvalues >> >> or >> >> row = db(...).select(db.table.record).first() >> >> db.other_table.field1.default = row.field >> >> form = SQLFORM(db.table, ...) >> >> Richard >> >> >> On Fri, May 2, 2014 at 9:07 AM, Oli <oliver...@gmx.net> wrote: >> >>> 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+un...@googlegroups.com. >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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. > -- 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.