Based on this partial model...

db.define_table('InfoSys',
    SQLField('ISName', 'string'),
    SQLField('ISAbbrev', 'string'),
    SQLField('ISType_id', db.ISType),
    SQLField('AppQuarter_id', db.AppQuarter),
    SQLField('ISOwnerType_id', db.ISOwnerType))

db.define_table('Assessment',
    SQLField('InfoSys_id', db.InfoSys),
    SQLField('AssessmentDateStart', 'date'),
    SQLField('AssessmentDateEnd', 'date'),
    SQLField('CAType_id', db.CAType),
    SQLField('AssessmentType_id', db.AssessmentType))

db.define_table('Doc',
    SQLField('Assessment_id', db.Assessment),
    SQLField('DocList_id', db.DocList),
    SQLField('DocVersionType_id', db.DocVersionType),
    SQLField('ClientStatusType_id', db.ClientStatusType),
    SQLField('ClientStatusDate', 'date'),
    SQLField('ClientStatusNote', 'text'))

... assume I am adding a new Doc record through "database
administration" on the Design tab (appadmin).

I want the Assessment_id field to be a drop down list containing three
pieces of information, all of which are in the referenced table
Assessment...
    InfoSys_id
    AssessmentDateStart
    AssessmentDateEnd

Now, in order to do this, I can create a validator something like
this...

db.Doc.Assessment_id.requires=IS_IN_DB(db,db.Assessment.id,'%
(InfoSys_id)s %(AssessmentDateStart)s %(AssessmentDateEnd)s')

Perfect.  So far, so good.  But here's my problem - InfoSys_id is a
foreign key and thus a number. What I really want is the data that
number represents, which is InfoSys.ISName.  How is it possible (or is
it possible) to represent InfoSys_id as InfoSys.ISName, along with the
two dates, in a drop down list?  I wrote a join query that returns the
required information, but can't figure out syntactically how to stuff
it into the validator (assuming it's even possible)...

db(db.Assessment.InfoSys_id==db.InfoSys.id).select(db.InfoSys.ISName)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to