For me this works
db.define_table('person',
Field('name'),
format = "%(name)s",
)
db.define_table('contributers',
Field('person', db.person), # <<< requires not necessary
)
def edit_contributer():
db.contributers.person.writable = False
record = request.args(0) # <<<< 0 not 1
form = crud.update(db.contributers, record)
return dict(form = form)
On May 18, 5:45 am, selecta <[email protected]> wrote:
> I have a similar problem
>
> db.define_table('person',
> Field('name'),
> format = "%(name)s",
> )
> db.define_table('contributers',
> Field('person', db.person, requires = IS_IN_DB(db,
> 'person.id', '%(name)s')),
> )
>
> def edit_contributer():
> db.contributers.person.writable = False
> record = request.args(1)
> form = crud.update(db.contributers, record)
> return dict(form = form)
>
> the update form will only display the id not the name field :(
>
> On May 17, 11:17 pm, howesc <[email protected]> wrote:
>
> > 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