You can't do that all at once when you respond to the initial request
because it depends on user input, so you have to populate the second select
via Ajax on the client side once the first selection is made. See
here<http://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910>for
some ideas.
Anthony
On Tuesday, August 14, 2012 2:49:28 PM UTC-4, lucas wrote:
>
> ok, what if i have a nested type select field like:
>
> db.define_table('class_assignments',
> Field('class_id', db.classes, requires=IS_IN_DB(db, db.classes.id,
> '%(class_title)s (%(id)s)'), writable=False, readable=False),
> Field('lecture_id', db.lectures,
> requires=IS_IN_DB(db(db.lectures.user_id == auth.user_id), db.lectures.id,
> '%(title)s (%(id)s)')),
> Field('lecture_item_id', db.lecture_items, requires=IS_IN_DB(db,
> db.lecture_items.id, '%(title)s (%(id)s)')),
> ...
>
> where in this case i want the user to select the lecture_id first, and
> then the lecture_item_id would be a subset or a detail list of the master
> lecture_id. i tried:
>
> Field('lecture_item_id', db.lecture_items,
> requires=IS_IN_DB(db(db.lecture_items.lecture_id == lecture_id),
> db.lecture_items.id, '%(title)s (%(id)s)')),
>
> and:
>
> Field('lecture_item_id', db.lecture_items,
> requires=IS_IN_DB(db(db.lecture_items.lecture_id ==
> db.class_assignments.lecture_id), db.lecture_items.id, '%(title)s
> (%(id)s)')),
>
> but both attempts failed. so how do i do a subselect kind of model?
> thanx in advance, lucas
>
>
--