You have two forms both called form (the second overwrites the first one) and you return only one of the
return dict(...,form=form) You should call them form1 and form2 and return both. On Dec 2, 9:52 am, Johann Spies <[email protected]> wrote: > Maybe I am just tired now. I am struggling to find the mistake and will > appreciate some help please. > > I want to select an ID from one table and use that ID to show the full > record from one table and related records from another table. > > Two problems: > > 1. If I use {{=form}} for the first form in ' show_fipil01' in the view I > get two identical fields/labels on the screen with one submit button. I > could 'solve' this problem using a custom form in the view. > > 2. When I select an id, no redirect takes place and the debugging line > (response.flash=repr(form.errors)) flash 'Storage {}' > I have also tried the redirect with > redirect(URL(r=request, f='show_fpipl01_data',vars=request_vars)) with > the same result. > > My controllers: > > def show_fpipl01_data(): > id = request.vars.id > form = crud.read('fpipl01',id) > data = SQLTABLE(db((db.fpipl01_data.form_id == id) & > (db.teacher.id == db.fpipl01_data.teacher) & > (db.school.id == db.fpipl01_data.school)).select( > db.fpipl01_data.form_id, > > db.teacher.surname, > > db.teacher.name, db.school.name, > > db.fpipl01_data.grade_taught), > headers = {'fpipl01_data.form_id' : 'Form ID', > 'teacher.surname' : 'Teacher surname', > 'teacher.name' : 'Teacher name', ' > school.name' : 'School', > 'fpipl01_data.grade_taught' : 'Grade > taught'}, > truncate = 25) > > message = 'FP/IP Literacy and English: Teacher training attendance > register (FPIPL01)' > return dict(form=form,data = data, message = message) > > def show_fpipl01(): > tabel = request.vars.tabel > tb = tabel.lower() > if auth.user_id in [21,22]: # Johann Spies (22) or ERA (21) > rdata = db((db.service_provider.id == db[tb].service_provider) > ).select(db[tb].id, > db.service_provider.name, > db[tb].date,db.fpipl01.trainer, > db[tb].focus) > > else: > rdata = db((db[tb].created_by==auth.user_id) & > (db.service_provider.id == db[tb].service_provider) > ).select(db[tb].id, > db.service_provider.name, > db[tb].date,db.fpipl01.trainer, > db[tb].focus) > > ids = [] > for row in rdata: > ids.append( row['fpipl01']['id']) > > data = SQLTABLE(rdata, > headers = {'fpipl01.id' : 'ID', ' > service_provider.name' : 'Service Provider', > 'fpipl01.date': 'Date', 'fpipl01.trainer': > 'Trainer', > 'fpipl01.focus': 'Focus of training'}, > truncate = 50 > ) > form = SQLFORM.factory(Field('id', requires = IS_IN_SET(ids), > label = "Which event (number)?") > ) > if form.accepts(request.vars, session): > redirect(URL(r=request, f='show_fpipl01_data',vars=form_vars)) > else: > response.flash=repr(form.errors) > > return dict(data=data,tabel=tabel,form=form) > > Regards > Johann > > -- > May grace and peace be yours in abundance through the full knowledge of God > and of Jesus our Lord! His divine power has given us everything we need for > life and godliness through the full knowledge of the one who called us by > his own glory and excellence. > 2 Pet. 1:2b,3a

