model
db.define_table('trainer',
Field('name'),
Field('specialty'),
auth.signature,
format='%(name)s',
migrate=True,
)
db.trainer.is_active.default=False
db.define_table('dogs',
Field('name'),
Field('bites', 'boolean'),
Field('trainer', 'reference trainer', default=1),
auth.signature,
format='%(name)s',
migrate=True,
)
controller
def assign_trainers():
db.dogs.trainer.requires = IS_IN_DB(db(db.trainer.is_active==False),
'trainer.id', '%(name)s',zero=T('choose one'))
search='trainer equal 1 or trainer equal 0'
#1 is the default value of a trainer named "Unassigned"
rows = db.smart_query([db.dogs], search).select()
grid = SQLFORM.smartgrid(db.dogs)
return locals()
view
{{extend 'layout.html'}}
<h2>Assign Trainers</h2>
<p>page used as an example posted to user group for help
{{=grid}}
{{=rows}}
The rows are what I want from the dogs thanks to smart_query() but they are
not in the "smart"grid.
The "smart"grid shows all the dogs but will not take rows as a paramter.
Click on the edit button and the edit page drop downs now only shows
trainers who's in_active field == False.
So I'm getting closer to my goal of making one grid with drop downs to
assign new trainers to new unassigned dogs.
my_need_for_help.is_active=True #still
-Bill
--