What is the context? Is the drop-down list part of a form based on a table with a reference to the "cities" table? In general, you can use the IS_IN_DB validator on a field to automatically generate a drop-down list:
SQLFORM.factory(Field('city', requires=IS_IN_DB(db, 'cities.id', '%(name)s'))) will produce a form with a drop-down list of the cities in the "cities" table. The list will include the city names, but the value submitted will actually be the record ID of the city from the "cities" table. IS_IN_DB can also be used as the 'requires' argument to Field() in db.define_table if you have a table that references the "cities" table. Anthony On Wednesday, February 1, 2012 3:25:26 PM UTC-5, shartha wrote: > > So the problem is two folds. I have defined a simple table as in: > > db = DAL("sqlite://storage.sqlite") > > db.define_table('cities', > Field('name'), > Field('state'), > ) > > > Now I'd like to have a drop-down list in my view that reads from the > name filed of the database cities. How can I achieve this? Any help > would be highly appreciated. > > Thanks! > S.