Are you sure you want the form readonly? What id you remove readonly? If you want readonly you do not need accepts
On Jan 26, 12:40 pm, Pawel Jasinski <[email protected]> wrote: > hi, > > hi, > i had the same idea in a mean time. Same effect :-( > --pawel > > On Jan 26, 6:25 pm, Massimo Di Pierro <[email protected]> > 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 <[email protected]> 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

