thanks .... though i figured out the issue. i was putting the "requires"
clauses for reference fields inside a []. when i removed it, the code
started working....... but thanks anyways bcos it showed me a new technique
nonetheless ..............
regards,
saikat
On Wed, Oct 29, 2008 at 1:42 PM, billf <[EMAIL PROTECTED]> wrote:
>
> The generation of a dropdown list is triggered by IS_IN_SET, e.g.
>
> db.animal.type.requires=IS_IN_SET(['dog','cat','parrot'])
>
> You can generate the option list from the db by something like:
>
> db.animal.type.requires=IS_IN_SET(db().select(db.animals.ALL))
>
> On Oct 29, 7:08 am, saikatsakura <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > My DB tables are as follows -
> >
> > #########################################################################
> > # This scaffolding model makes your app work on Google App Engine
> > too #
> > #########################################################################
> >
> > try:
> > from gluon.contrib.gql import * # if running on Google App
> > Engine
> > except:
> > db=SQLDB('sqlite://db.db') # if not, use SQLite or other
> > DB
> > else:
> > db=GQLDB() # connect to Google
> > BigTable
> > session.connect(request,response,db=db) # and store sessions there
> > #session.forget() # uncomment for no session
> > at all
> >
> > #########################################################################
> > # Define your tables below, for
> > example #
> > #
> > #
> > # >>>
> > db.define_table('mytable',SQLField('myfield','string')) #
> > #
> > #
> > # Fields can be
> > 'string','text','password','integer','double','booelan' #
> > # 'date','time','datetime','blob','upload', 'reference
> > TABLENAME' #
> > # There is an implicit 'id integer autoincrement'
> > field #
> > # Consult manual for more options, validators,
> > etc. #
> > #
> > #
> > # More API examples for
> > controllers: #
> > #
> > #
> > # >>>
> > db.mytable.insert(myfield='value') #
> > # >>>
> > rows=db(db.mytbale.myfield=='value).select(db.mytable.ALL) #
> > # >>> for row in rows: print row.id,
> > row.myfield #
> > #########################################################################
> >
> > import datetime
> > now = datetime.date.today()
> >
> > db.define_table('category',SQLField('name'))
> >
> > db.define_table('recipe',
> > SQLField('title'),
> > SQLField('description',length=256),
> > SQLField('category',db.category),
> > SQLField('date','date',default=now),
> > SQLField('instructions','text'))
> >
> > db.category.name.requires =
> > [IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'category.name')]
> > db.recipe.title.requires = [IS_NOT_EMPTY()]
> > db.recipe.description.requires = [IS_NOT_EMPTY()]
> > db.recipe.category.requires =
> > [IS_IN_DB(db,'category.id','category.name')]
> > db.recipe.date.requires = IS_DATE()
> >
> > However, the dropdown for categories is not coming when trying to add
> > a recipe. what is the mistake did i do?
> >
> > regards,
> > saikat
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---