Correction should be 
requires=IS_IN_DB(db(db.category.id>0),...) 
not requires=IS_IN_DB(db.category,...)


form = SQLFORM.factory(Field("category",label="Book Category", 
requires=IS_IN_DB(db(db.category.id>0), 'category.id', 'category.name', 
error_message="Please pick a category from the list")))

if form.accepts(request.vars, session, keepvalues=True):
    
    powerTable = plugins.powerTable
    powerTable.datasource = 
db(db.book.category==request.vars.category).select(db.category.ALL) 
#DAL query!
    powerTable.headers = 'labels' #Add a label="some text" to your fields in 
the model & it'll be used else it'll try to use the field's name
    powerTable.columns=['book.name', 'book.code']
    books = powerTable.create()
else:
    books = None
return dict(form = form, books = books)

Reply via email to