Hi, i have this defined as a model:
db.define_table('question',
Field('question', 'string', length=1056, notnull=True, unique=True,
requires=[IS_NOT_EMPTY(),
IS_NOT_IN_DB(db,'question.question')]),
#version info
Field('created_by', db.auth_user, default=auth.user_id,
writable=False),
Field('created_on','datetime', default=request.now,writable=False),
Field('updated_by',db.auth_user,
default=auth.user_id,update=auth.user_id,writable=False),
Field('updated_on','datetime',
default=request.now,update=request.now,writable=False),
migrate=migrate,
format='%(question)s (%(id)s)')
then, in tables that reference it, when the reference field is not
writable it uses the format string set at the end of the table
definition instead of just the ID.
hope that helps,
cfh
On May 17, 10:20 am, mdipierro <[email protected]> wrote:
> yes. I misread the previous emails so my answer was wrong.
>
> On May 17, 11:22 am, Iceberg <[email protected]> wrote:
>
> > Not sure. Can't Field(..., writable=False) do the trick?
>
> > On May17, 5:44pm, Andrew Buchan <[email protected]> wrote:
>
> > > Hi all,
> > > If I have a referenced field where I specify which field in the
> > > referenced table to display, like so:
> > > Field('To_Department', requires = IS_IN_DB(db, db.department.id,
> > > '%(Department_Name)s')),
> > > SQLFORM generates a form with a drop-down box showing me the
> > > Department_Name of the departments, but only if it is an INSERT or UPDATE
> > > form.
> > > My question is, how do I get a read-only form to display the
> > > Department_Name instead of the id of the referenced record?
> > > Can't seem to find an example or answer on the web, but there must surely
> > > be an easy way...
> > > Thanks,Andy.
>
> > > _________________________________________________________________http://clk.atdmt.com/UKM/go/197222280/direct/01/
> > > Do you have a story that started on Hotmail? Tell us now