Hi Bernardo, you would have to add a represent to table2.reference_table1:
db.table2.reference_table1.represent = lambda v: '%(atribute1)s' %db.table1[v] requires is used during input while represent is for output. Denes On Oct 13, 5:05 am, Bernardo <[email protected]> wrote: > Dear all, > > When making a form using SQLFORM, everything goes fine until I use the > readonly=True statement. I then just shows the id (and not the name of > the record). > > For example: > > I have two tables like this > > db.define_table('table1', > Field('atribute1', 'string') > ) > > db.define_table('table2', > Field('reference_table1', db.table1, requires = IS_IN_DB(db, > 'table1.id', '%(atribute1)s')), > Field('atribute2', 'string') > ) > > If my SQLFORM is: > form = SQLFORM(db.table2, record = request.args(0), > fields=['reference_table1', 'atribute2']) > > Then everything goes perfect. It shows a form to modify this record, > with the atribute1 value from the referenced record of table1. > > But if the SQLFORM is: > form = SQLFORM(db.table2, record = request.args(0), readonly=True, > fields=['reference_table1', 'atribute2']) > > The form shown, is a readonly form(which is right), but the value > shown in the reference_table1 is not atribute1, but the id from the > record on table1. > > How can I solve this? > > If I have not explained myself clearly enough, please do not hesitate > on asking me further. > > Thanks and kind regards, > Bernardo

