Question on linking fields

50 views
Skip to first unread message

Greg Vaughan

unread,
Feb 16, 2014, 1:34:46 PM2/16/14
to web...@googlegroups.com
Hi everyone...

Linked tables like...

db.define_table('calls',
    Field('business', 'string'),
    ...

and

db.define_table('leads',
    Field('business', 'reference calls'),
    ...

with controller containing

def calls():
    form = SQLFORM(db.calls)
    if form.process().accepted:
        redirect(URL('leads'))

and form

{{extend 'layout.html'}}
{{=form}}

create a drop down linking list for the "Business" field...

How can I make this default to the record that has just been created in 'calls' instead?

Jim S

unread,
Feb 17, 2014, 3:45:40 PM2/17/14
to web...@googlegroups.com
Not tested, but something like this maybe??

def calls():
form = SQLFORM(db.calls)
if form.process().accepted:
redirect(URL('leads',vars={'id':id}))

def leads():
db.leads.business.default = call_id
form = SQLFORM(db.leads)
if form.process().accepted:
redirect(...to the next place you're going)

Greg Vaughan

unread,
Feb 18, 2014, 7:10:06 AM2/18/14
to web...@googlegroups.com
Hi Jim

That was exactly what I needed thanks so much. Works perfectly.

Jim Steil

unread,
Feb 18, 2014, 10:24:06 AM2/18/14
to web...@googlegroups.com
Glad to help.


On Tue, Feb 18, 2014 at 6:10 AM, Greg Vaughan <greg.s....@gmail.com> wrote:
Hi Jim

That was exactly what I needed thanks so much. Works perfectly.

--
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/eYOJtIjxCYg/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.

Reply all
Reply to author
Forward
0 new messages