Thanks Massimo ! I've tried to use SQLFORM before but it displays also the ID even if I do not include it in the fields list. Furthermore I need to change some fields defaults such as TEXTAREA size etc... (in my app there are more than 1 field)
---------------------------- Sebastian E. Ovide On Wed, May 6, 2009 at 6:52 PM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > You can do > > if form.accepts(request.vars,session,keepvalues=True) > > You can also simplify your code > > def test(): > tests = db(db.tests.owner_id==auth.user.id).select() > if tests: > form=SQLFORM(db.tests,tests[0],fields=['name']) > if form.accepts(request.vars,session): > # session.flash = '....' > redirect(URL(r=request,f="test")) > else: > form=None > return dict(form=form) > > > > On May 6, 12:20 pm, "Sebastian E. Ovide" <sebastianov...@gmail.com> > wrote: > > Hi All, > > > > in an action that updates a FORM , when the form accepts the new values, > it > > updates the DB correctly, but when redraw the page it display the old > > values. If I press Submit again (keeping the old values in the form) it > > displays the new values entered previously... and so on for ever.... > > > > the work around was to add a redirect to the same controller just after > the > > db.update. > > > > Is it the correct way to deal with custom FORMS ? Am I missing something > ? > > > > thanks > > > > def test(): > > form = None > > # find tests profile of current user > > query=db.tests.owner_id==auth.user.id > > tests = db(query).select() > > if len(tests)>0: > > #get the first found > > test=tests[0] > > > > form=FORM(TABLE(TR("Name:",INPUT(_type="text",_name="name",value= > > test.name,requires=IS_NOT_EMPTY())), > > TR("",INPUT(_type="submit",_value="SUBMIT")) > > )) > > > > if form.accepts(request.vars,session): > > db(query).update(name=form.vars.name) > > # HERE THE REDIRECT !!!!!! > > redirect(URL(r=request,f="test")) > > > > return dict(form=form) > > > > ---------------------------- > > Sebastian E. Ovide > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@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 -~----------~----~----~----~------~----~------~--~---