Hi Anthony and Jim, thanks very much for your help. I got it working with Jim suggestion since I only wanted to insert a completely new record with the prepopulated values from the previous sqlgrid form.
thanks again! regards, John On Wednesday, February 12, 2014 3:40:27 PM UTC+1, Anthony wrote: > > Do you want to actually update the record in question, or simply insert a > completely new record that is prepopulated with the values from this > record? If the former, then just pass the record ID in the URL and pass > that ID to SQLFORM in order to create an update form. > > Anthony > > On Wednesday, February 12, 2014 9:19:36 AM UTC-5, Jim S wrote: >> >> So, with this statement: >> >> addpass = [lambda project: A('add pass', _class="btn", >> _href=URL("default","addpass"))] >> >> You're creating a link to an entirely different controller, right? >> >> If that is correct then I would pass the parameters for that 'project' as >> vars on the URL command as such: >> >> addpass = [lambda project: A('add pass', _class="btn", >> _href=URL("default","addpass",vars={'DOY':project.DOY, >> 'STATION':project.STATION, 'BOT':project.BOT, 'EOT':project.EOT}))] >> >> ...assuming you know all your values you wish to pass when the button is >> being created. >> >> Then in default/addpass use this: >> >> db.nextpasses.DOY.default = request.get_vars.DOY >> db.nextpasses.STATION.default = request.get_vars.STATION >> db.nextpasses.BOT.default = request.get_vars.BOT >> db.nextpasses.EOT.default = request.get_vars.EOT >> >> Not sure if this is what you're after or if this is even the best >> solution. But, may spark some thoughts in others on the list too. >> >> Hope it helps. >> >> -Jim >> >> >> >> On Wed, Feb 12, 2014 at 4:37 AM, John Philip <ajmoll...@googlemail.com>wrote: >> >>> Hi Jim, thanks for you reply. Sorry I guess I should be more specific. I >>> have a SQLGRID form (displaying contents of table db.nextpasses) , In the >>> SQLFORM.grid I have inserted a button called addpass so for every record in >>> the SQLgrid I have a button addpass. When clicking "addpass" another form >>> "addpass" is opened which should be pre-populated from the record values in >>> the SQLform.grid in the previous form. >>> >>> maybe something like this >>> >>> sgrid = SQLFORM.grid(db.nextpasses, >>> links=addpass(db.addpass.field_name.default = db.nextpasses.field_name >>> >>> I am bit confused where I need to pass the values when initiating the >>> lamba project addpass. >>> >>> thanks, >>> John >>> >>> >>> >>> >>> On Tuesday, February 11, 2014 10:16:28 PM UTC+1, Jim S wrote: >>>> >>>> Try setting the defaults on the respective fields: >>>> >>>> db.nextpasses.field_name.default = default_value_for_this_field >>>> >>>> -Jim >>>> >>>> On Tuesday, February 11, 2014 10:51:29 AM UTC-6, John Philip wrote: >>>>> >>>>> Hi there, >>>>> >>>>> I am a newbie to web2py. I did try to look for similar threads but >>>>> couldn't find a solution specifically for my problem. I want to >>>>> pre-populate a form from a current record in the SQLFORM.grid. >>>>> >>>>> addpass = [lambda project: A('add pass', _class="btn", >>>>> _href=URL("default","addpass"))] >>>>> # added a link button to open form addpass which should have >>>>> pre-populated fields in sgrid shown below. >>>>> >>>>> sgrid = SQLFORM.grid(db.nextpasses, links=addpass, create=False, >>>>> editable= False, deletable=False, fields=[db.nextpasses.DOY,db. >>>>> nextpasses.STATION,db.nextpasses.BOT,db.nextpasses.EOT], >>>>> maxtextlength=50,headers={'nextpasses.DOY' : >>>>> 'DOY','nextpasses.STATION' : 'Station', 'nextpasses.BOT' : 'Aos', >>>>> 'nextpasses.EOT' : 'Los'}) >>>>> >>>>> Any help would be greatly appreciated! >>>>> >>>>> many thanks and regards, >>>>> >>>>> John Philip >>>>> >>>>> -- >>> 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 a topic in the >>> Google Groups "web2py-users" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/web2py/-bzBmvCsYyQ/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> web2py+un...@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- 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/groups/opt_out.