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