Have you looked at using mydb.mytable.myfield.default=.... pattern? You can copy standard fields this way, by selecting a record, saving it in a row, and using that as the default field. The default fields can change programmatically (so they can be different over execution, e.g. one thing at table definition, but customized in a controller).
See http://groups.google.com/group/web2py/browse_thread/thread/ec1d5568db2598e6 or (if you're using t2.create) http://groups.google.com/group/web2py/browse_thread/thread/a67e2aa25108dac7/b13a12a9b0c4060d?lnk=gst&q=default+form+values#b13a12a9b0c4060d Hope that helps. Yarko On Tue, Dec 30, 2008 at 9:13 AM, notabene <[email protected]> wrote: > > Thank You very much for Your suggestions. > > But ... > > The copy function was not meant as a record copy function - but as a > t2.create function where a record was used as default values in the > form. > > Regarding the popup-window. > That is must usefull. But I don't see where the manipulation/edit of a > field on the calling page/form can take place? Can it be done from the > edit-function in the controller or is it a javascript callback > function? > > Niels > > On Dec 28, 3:33 pm, mdipierro <[email protected]> wrote: > > 1) > > > > def mycopy(table,id): > > records=table._db(table.id==id).select() > > if not records: return False > > table.insert(**dict([(x,records[0][x]) for x in table.fields if > > not x=='id'])) > > return True > > > > use it as in mycopy(db.puppy,3) > > > > 2) this is very much open ended. For example you can do in a view > > > > <button onclick="popup('{{=URL(r=request,f='edit',args= > > ['table','field','id'])}})">click me</button> > > > > replace table, field, id with values. > > > > and a controller like: > > > > @t2.requires_login() > > def edit(): > > table,field,id=request.args[0],request.args[1],request.args[2] > > form=SQLFORM(db[table],db(db[table].id==id).select()[0],fields= > > [field]) > > if form.accept(request.vars,session): return HTML(BODY(SCRIPT > > ('window.close()'))) > > return HTML(BODY(form)) > > > > Massimo > > On Dec 28, 6:36 am, notabene <[email protected]> wrote: > > > > > I need 2 patterns - and I believe they would be usefull in general: > > > - t2.copy to supplement insert, update, delete. > > > - a popup page - attached by an edit or search button to a field - > > > which can be customized to supply the field-content. > > > > > I am not that experienced in web2py and python, and would appreciate > > > help from the community (/massimo?) > > > > > Regards > > > > > Niels Bjerre > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

