Sorry, not sure I follow.
In my example, helpdeskTech is a subset of auth_user. My 'ticket' has a
helpdeskTechId (in the assignedTo field), not an id from the auth_user
table. I want my select tag to display the auth_user name, but return
the helpdeskTechId from the helpdeskTech table.
Maybe I don't fully grok the IS_IN_DB and the way the parms work. I'll
go back and look that over again.
-Jim
On 5/7/2012 3:59 PM, Richard Vézina wrote:
auth_user_rows = db().select(db.auth_user.id <http://db.auth_user.id>)
make a set :
auth_user_set = ((db.auth_user.id <http://db.auth_user.id> ==
rows.first().id)|(db.auth_user.id <http://db.auth_user.id> ==
rows.last().id))
IS_IN_DB(auth_user_set,...)
Richard
On Mon, May 7, 2012 at 4:37 PM, Jim Steil <[email protected]
<mailto:[email protected]>> wrote:
Hi
I am having trouble getting my list to display the way I want it to.
Given the following definition:
-----------------------
helpdeskTech = db.define_table('helpdeskTech',
Field('helpdeskTechId', 'id', readable=False),
Field('helpdeskId', db.helpdesk, required=True, label='Helpdesk'),
Field('userId', db.auth_user, required=True, label='User'),
format='%(userId.lastFirst)s')
helpdeskTech.helpdeskId.requires = IS_IN_DB(db, db.helpdesk,
'%(name)s',
zero='...choose...')
helpdeskTech.userId.requires = IS_IN_DB(db, db.auth_user,
'%(lastFirst)s',
zero='...choose...')
helpdeskTech['_plural'] = 'Technicians'
ticket = db.define_table('ticket',
Field('ticketId', 'id', readable=False),
Field('helpdeskId', db.helpdesk, required=True, label='Helpdesk'),
Field('name', length=100, required=True),
Field('description', 'text'),
Field('createdOn', 'date', label='Created'),
Field('createdBy', db.auth_user, required=True, label='Creator'),
Field('assignedTo', db.helpdeskTech, label='Assigned To'),
Field('priority', length=10, required=True),
Field('status', length=10, required=True),
format='%(name)s')
ticket.helpdeskId.requires = IS_IN_DB(db, db.helpdesk,
'%(name)s',
zero='...choose...')
ticket.name.requires = IS_NOT_EMPTY()
ticket.createdOn.requires = IS_DATE('%m/%d/%Y')
ticket.createdBy.requires = IS_IN_DB(db, db.auth_user,
'%(lastFirst)s',
zero='...choose...')
ticket.assignedTo.requires = IS_NULL_OR(IS_IN_DB(db, db.helpdeskTech,
zero='...choose...'))
-----------------------
I want my IS_IN_DB validator in the last line to display the last
name and first name from the auth_user table.
But, what I'm getting is the helpdeskTechId field displaying.
I'm wondering how I can refer back to the auth_user table to get
the names to display in the dropdown instead of the helpdeskTechId
without custom-coding the view.
Thoughts?
-Jim