hi, hi, i had the same idea in a mean time. Same effect :-( --pawel
On Jan 26, 6:25 pm, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > I will double check because clearly something is wrong. Meanwhile, how > about this: > > db.define_table('foo', Field('x'), format='%(x)s') > db.define_table('bar', Field('label'), Field('ref',db.foo)) > in controller: > def insertone(): > id=db.foo.insert(x="xxx") > db.bar.insert(label="label",ref=id) > def index(): > record=db.bar(id=1) > form=SQLFORM(db.bar,record,readonly=True) > if form.accepts(request.vars,session): > session.flash="accepted" > return dict(form=form) > > On Jan 26, 10:37 am, Pawel Jasinski <pawel.jasin...@gmail.com> wrote: > > > Hi, > > > I just hit the same problem and can reproduce in trivial case > > > in model: > > db.define_table('foo', Field('x')) > > db.define_table('bar', Field('label'), Field('ref',db.foo)) > > > in controller: > > def insertone(): > > id=db.foo.insert(x="xxx") > > db.bar.insert(label="label",ref=id) > > > def index(): > > record=db.bar(id=1) > > form=SQLFORM(db.bar,record,readonly=True) > > if form.accepts(request.vars,session): > > session.flash="accepted" > > return dict(form=form) > > > this will produce 'None' on the ref field > > if I change index to be: > > > def index(): > > record=db.bar(id=1) > > db.bar.ref.represent=lambda val: db.foo[val].x > > form=SQLFORM(db.bar,record,readonly=True) > > if form.accepts(request.vars,session): > > session.flash="accepted" > > return dict(form=form) > > > everything is tiptop > > web2py version: 1.91.6 > > > Cheers, > > Pawel > >