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
<[email protected]>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
> [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.