Almost straight from the book but using my own db fields - tested and 
works...

This controller in default.py

def from_factory():
    form = SQLFORM.factory(Field('your_name', requires = 
IS_IN_DB(db,db.person.id,'%(first_name)s')))
    if form.process().accepted:
        response.flash = 'form accepted'
        session.your_name = form.vars.your_name
    elif form.errors:
        response.flash = 'form has errors'
    return dict(form=form)


with this view 'from_factory.html'

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


gives a drop down list of person's first_names.

The selected name is now held in the cookie  'session.your _name'

but if you want the table id then,

replace...        session.your_name = form.vars.your_name

with something like ...       session.person_id = form.vars.id

Hope this helps.

Peter





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

Reply via email to