Thanks Vinicius. I adopted your suggestion, although I really like the idea 
of defining all the widgets at the model level and this approach does not 
conform to it.

If say the constraint on continent was made on another table and selected 
prior to this form, i.e. we know what it is before the countries form is 
shown, I am wondering if there is a way to add a filter to the options 
widget?


On Wednesday, 2 January 2013 20:13:46 UTC+8, viniciusban wrote:
>
> Ajax will help you. 
>
> You need to load countries HTML OPTION's when continent changes. 
>
>
>
> On Wed, Jan 2, 2013 at 3:26 AM, Calvin <calvi...@gmail.com <javascript:>> 
> wrote: 
> > Say I have a look-up tables as follows: 
> > 
> > db.define_table('continent', 
> >    Field('name') 
> > ) 
> > 
> > 
> > db.define_table('country', 
> >    Field('name'), 
> >    Field('in_continent', db.continent, requi) 
> > ) 
> > 
> > Now, if I then have a table as defined: 
> > 
> > 
> > 
> > I would then like to have an SQLFORM in which field country presents a 
> list 
> > in an options dropdown box with only countries based on what continent 
> is 
> > selected in the record but I am not able to figure out the correct 
> syntax. 
> > 
> > 
> > db.define_table('where_is_carmen', 
> >   Field('continent', db.continent, default= 1, requires = IS_IN_DB(db, 
> > 'continent.id', '%(name)s'), represent = lambda value, row: 
> > db.continent[value].name), 
> >   Field('country', db.country, requires = lambda id: 
> > 
> IS_EMPTY_OR(IS_IN_DB(db(db.country.continent==(db.where_is_carmen[id].continent
>  
>
> > if id else db.where_is_carmen.continent.default)), 'country.id', 
> > '%(name)s'))) 
> > ) 
> > 
> > 
> > I would then like to have an SQLFORM in which field country presents a 
> list 
> > in an options dropdown box with only countries based on what continent 
> is 
> > selected in the record but I am not able to figure out the correct 
> syntax. 
> > 
> > Any light shed on how this could be done would be much appreciated. 
> > 
> > -- 
> > 
> > 
> > 
>

-- 



Reply via email to