I posted in this 
thread https://groups.google.com/forum/#!topic/web2py/2i9zfAzG2s8 but 
posted after it was closed.  Evidently, this is fixed but I'm still not 
seeing my 'formats' for foreign keys.  Here are the details:

I have this in my db.py:

db.define_table('customer',
Field('customerId', 'id', readable=True, writable=False, label='Customer 
#'),
Field('name', length=30, required=True, writable=False,
  requires=IS_NOT_EMPTY()),
Field('city', length=30, writable=False),
Field('state', length=2, writable=False),
format='%(customerId)s - %(name)s - %(city)s, %(state)s')

db.define_table('equip_order',
Field('id', 'id', readable=False, label='Order #'),
Field('order_type', 'reference orderType', label='Order Type', 
ondelete='RESTRICT',
   requires = IS_IN_DB(db(db.orderType.equipment==True),
   'orderType.id', '%(name)s', zero='..')),
Field('status', length=10, default='New',
   requires=IS_IN_SET(('New', 'Submitted', 'Invoiced'))),
Field('customer', 'reference customer', label='Customer', 
ondelete='RESTRICT'))

When I display (VIEW MODE) the customer field in the equip_order table in a 
custom SQLFORM.grid form using:

{{=form.custom.widget.customer}}

...it displays the id of the customer, not the name.

I thought the 'format' on the customer table definition would control this. 
I know I can fix it by changing the definition of the customer field in the 
equip_order table to:

Field('customer', 'reference customer', label='Customer', 
ondelete='RESTRICT',
   represent=lambda x, r: '%s - %s - %s, %s' % (db.customer(x).customerId
db.customer(x).name,
db.customer(x).city,
db.customer(x).state) if x else ''),

Should I have to do that, or should the 'format' on customer take care of 
it?

-Jim

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to