There are two nifty functions for this: DIV.element and DIV.elements. Building on the example above, you can grab and modify all text inputs like this:
inputs = form.elements("input",type="_text") for inp in inputs: inp['_whatever'] = session.whatever On Nov 16, 4:01 pm, Dmitri Zagidulin <dzagidu...@gmail.com> wrote: > Ah, ok! Makes sense, I'll try that. > > But there aren't any form dictionaries of values that I can update, > right? Something like: > form.custom.fieldvalues.update(session.myrecord) ? > > On Nov 16, 4:48 pm, "mr.freeze" <nat...@freezable.com> wrote: > > > Try using the 'default' attribute of SQLFORM to set the value to your > > session value. Something like this: > > > def index(): > > form = SQLFORM.factory(Field('test1',default=session.test1), > > Field('test2',default=session.test2), > > submit_button="Next") > > if form.accepts(request.vars,session): > > session.test1 = request.vars.test1 > > session.test2 = request.vars.test2 > > redirect(URL(r=request,f='index2')) > > return dict(form=form) > > > On Nov 16, 2:55 pm, Dmitri Zagidulin <dzagidu...@gmail.com> wrote: > > > > The setup: > > > I'm working on a 3-step editing wizard, so, 3 pages with a form on > > > each page. The navigation between the pages is done via Next and > > > Previous submit buttons. When you go from page 1 to page 2, the > > > contents of the form on page 1 are stored in the session. All 3 pages > > > are written to the database when they complete step 3 -- until then > > > they remain in the session. > > > For each page, I'm using SQLFORM.factory to create the forms, and > > > using a custom layout via {{=form.custom.widget.myfield}} in the view. > > > > I got it working to the extent that I fill out the form on page 1, hit > > > 'Next', and I can verify that the values from form 1 are stored in the > > > session. > > > My question is this: > > > When I'm on page 2 and hit 'Back', how do I get the custom form 1 to > > > use the values stored in the session as the field values? > > > That is, how do I use SQLFORM.factory as an edit form (given that I > > > have a dictionary of key-value pairs, with the keys being the field > > > names)? > > > > Similarly, if I want to edit a record from the database, and need the > > > custom layout that SQLFORM.factory provides, and I load the record > > > from the db, how do I make the form use those values I loaded? > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" 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 -~----------~----~----~----~------~----~------~--~---