Thanks, I indeed missed that hidden field with record id. From the book: "Edit forms also contain a hidden INPUT field with name="id" which is used to identify the record. "
Though I don't really understand why we need that field as record id is kept server-side anyway. On Thursday, August 29, 2013 4:32:52 PM UTC+3, viniciusban wrote: > > It would be nice if you show your view. > > Probably you're missing a hidden field in second form with the record id. > > On Thu, Aug 29, 2013 at 10:12 AM, <shapova...@gmail.com <javascript:>> > wrote: > > Hi! > > > > I have an issue with UPDATE form. I'm trying to implement something like > > enrollment form that has man field beyond standard name, email, etc. For > the > > sake of usability I've decided to split it to two steps (i.e. > controllers - > > pages): first asks user for name and email, and after user submits it, > > he/she gets redirected to the second controller with UPDATE form for the > > same record, inserted with previous form. > > > > Btw, at first I thought of having a one page form and presenting it in > parts > > with help of JS, but I've decided to go with back end, to have even > > partially submitted data in database. > > > > def firstform(): > > form = SQLFORM(db.person, fields = ['email','name']) > > if form.process(session=None, formname='begin_form').accepted: > > session.person_id = form.vars.id > > session.flash = 'form accepted' > > redirect(URL('endjoin')) > > elif form.errors: > > response.flash = 'form has errors' > > else: > > response.flash = 'please fill the form' > > return dict() > > > > # and > > def secondform(): > > record = db.person(session.person_id) or redirect(URL('index')) > > form = SQLFORM(db.person, record, fields = > > ['address','phone','many_more_fields']) > > if form.process(session=None, formname='end_form').accepted: > > response.flash = 'form accepted' > > elif form.errors: > > response.flash = 'form has errors' > > else: > > response.flash = 'please fill the form' > > return dict() > > > > The problems is that second action 'firstform' makes insert, instead of > > update to the record inserted by first action 'secondform'. Though > 'record' > > contains reference to last add row, which should be updated(completed). > I'm > > not passing form to the view, I use custom html to present my forms, > because > > I didn't find a way to make helpers specify input type='email', > placeholder, > > size and other HTML5 form parts attributes. > > > > -- > > > > --- > > You received this message because you are subscribed to the Google > Groups > > "web2py-users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to web2py+un...@googlegroups.com <javascript:>. > > For more options, visit https://groups.google.com/groups/opt_out. > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.