wicked cool
thanks a bunch !
On Friday, May 23, 2014 3:28:43 PM UTC+2, Anthony wrote:
>
> You can use a lambda:
>
> db.define_table('other_table',
> Field('key_id', 'reference key',
> requires=IS_IN_DB(db, 'key.id', lambda r: '%s %s (%s)' % (r.
> person_id.first_name,
> r.
> person_id.last_name, r.id))))
>
> Anthony
>
> On Friday, May 23, 2014 5:38:21 AM UTC-4, Louis Amon wrote:
>>
>> Say I have a table like this:
>>
>> db.define_table('person', Field('first_name'), Field('last_name'),
>> format='%(first_name)s %(last_name)s'
>>
>> Now if I build a new table:
>>
>> db.define_table('key', Field('person_id', 'reference person',
>> requires=IS_IN_DB(db, db.person, label=db.person._format)))
>>
>> My new table 'key' will represent its references using 'person' table's
>> format.
>>
>>
>> But what if I have another table like this:
>>
>> db.define_table('other_table', Field('key_id', 'reference key',
>> requires=IS_IN_DB(db, db.key, label='%(first_name)s %(last_name)s
>> (%(key_id)s)'???)))
>>
>>
>> How do I define the label in 'other_table' so that it shows the 'person'
>> that this key is actually referring to ?
>>
>>
>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.