Hmm oke. I tried it on different ways. Now i use the PowerTable plugin and 
it's working. There is nothing wrong with the IS_IN_DB() validator as far 
as i can see. I use:

db.define_table('clients',
                 Field('number'),
                 Field('name'),
                 Field('created_on','datetime', default=request.now,update=
request.now,writable=False, readable=False),
                 Field('created_by',db.auth_user, default=auth.user_id,
update=auth.user_id,writable=False,readable=False),
                 format='%(name)s'
                 )
 
db.define_table('sessions',
                 Field('client_id', db.clients),
                 Field('creation_date'),
                 Field('created_on','datetime', default=request.now,update=
request.now,writable=False, readable=False),
                 Field('created_by',db.auth_user, default=auth.user_id,
update=auth.user_id,writable=False, readable=False),
                 )
 
db.sessions.client_id.requires = IS_IN_DB(db, db.clients.id, '%(name)s')

Maybe i'm missing something. I also tried to use the following way to 
define the IS_IN_DB():

db.define_table('sessions',
                 Field('client_id', db.clients, requires=IS_IN_DB(db, db.
clients.id, %'name's)),

But also no success. For now I'm going to use the PowerTable plugin but if 
you can find my blind spot on this, please let me know!

Thanks a lot for helping!

 Remco


On Monday, July 9, 2012 7:34:40 PM UTC+2, Anthony wrote:
>
> On Monday, July 9, 2012 12:32:11 PM UTC-4, Remco K wrote:
>>
>> Thanks for the answers.
>>
>> This representation works perfectly when i show the content in a dropdown 
>> so i think this has more to do with SQLFORM.grid...
>>
>
> The dropdown is controlled by the IS_IN_DB validator, not the field's 
> "represent" attribute. SQLFORM.grid, SQLTABLE, and read-only SQLFORMs, 
> however, depend on the represent attribute. If you set the "format" 
> attribute of the referenced table and do not explicitly set your own 
> IS_IN_DB validator for the reference field, then the reference field will 
> adopt that format attribute for both its IS_IN_DB validator and its 
> represent attribute -- otherwise, you have to handle each separately.
>
> Anthony
>

Reply via email to