like request.accept(keepvalues=True)... but only if there was an error. -Thadeus
On Sat, Jan 9, 2010 at 11:32 PM, mdipierro <mdipie...@cs.depaul.edu> wrote: > You can simplify your code > > def diag_form(): > form = SQLFORM(db.socdiag, request.args(0), deletable=True) > if form.accepts(request.vars, session): > response.flash = 'form accepted' > elif form.errors: > # (1) > response.flash = 'form has errors' > return dict(form=form) > > I am not sure what you asked. Try insert in (1) > > form.vars.update(request.vars) > > OR > > if form.record: form.vars.update(form.record.as_dict()) > > OR > > [form.vars[key]=db.socdiag[key].default for key in > db.socdiag.fields] > > Does of them solves your problem? > > On Jan 9, 5:12 pm, Jeff Bauer <jeffru...@gmail.com> wrote: >> I'm following another example in the manual using SQLFORM. >> The code works as advertised. The only fly in the ointment >> is when form.errors is True, the user's entry form no longer >> displays her original values. I'm assuming there's a simple >> way to pass the request vars back into form at line 11 >> before return. >> >> 1 def diag_form(): >> 2 if len(request.args): >> 3 records = db(db.socdiag.id==request.args[0]).select() >> 4 if len(request.args) and len(records): >> 5 form = SQLFORM(db.socdiag, records[0], deletable=True) >> 6 else: >> 7 form = SQLFORM(db.socdiag) >> 8 if form.accepts(request.vars, session): >> 9 response.flash = 'form accepted' >> 10 elif form.errors: >> 11 response.flash = 'form has errors' >> 12 return dict(form=form) >> >> Jeff Bauer >> Rubicon, Inc. > > -- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To post to this group, send email to web...@googlegroups.com. > To unsubscribe from this group, send email to > web2py+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/web2py?hl=en. > > > >
-- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.