Tryin to use the example shown in Validators between classical and 
professional usage <http://web2py.wordpress.com/category/web2py-validators/>to 
change the values and widget for an SQLFORM.grid.

I need to display an "Assign Trainers" page with an SQLFORM.grid (or 
something similar) of new dogs that have not been assigned to a trainer but 
can only be assigned to new trainers that have not been given dogs. So I 
thought simple query the is_active property on both cases, append the 
validator make (& process) my form. 

db.define_table('trainer',
    Field('name'),
    Field('specialty'),
    auth.signature,
    format='%(name)s')
db.trainer.is_active.default=False

db.define_table('dogs',
    Field('name'),
    Field('bites', 'boolean'),
    Field('trainer', 'reference trainer', 
              default=1,
              widget=SQLFORM.widgets.options.widget,
              requires=[IS_IN_DB('db.trainer', 
              IS_UPPER())]),
    auth.signature,
    migrate=True)

db.dogs.is_active.default=False

Controller:
def assign_trainers():
    trainers=db(db.trianer._is_active==False)
    new_dogs=db(db.dogs._is_active==False)
    new_dogs.trainer.requires.append(IS_IN_SET(trainers))
    
    grid = SQLFORM.grid(new_dogs)
    
    return locals()

Been working on this solution for two days now. Read all the books, bought 
the 
Cookbook<https://play.google.com/books/reader?id=cwjpG47z_7IC&printsec=frontcover&output=reader&authuser=0&hl=en&pg=GBS.PA1>read
 the blogs and now I'm out of time with my prototype presentation due 
Thursday.

ANY help is very much needed at this point.

Thank you,
Bill




-- 



Reply via email to