Thank you Massimo, But
db.user.id.default = user.user.id db.user.name.default = user.user.name db.user.email.default = user.user.email db.addr.city.default = user.addr.city is the rigth way to preopulate a SQLFORM.factory form????? Why not once the form is defined, can I do form.vars.title = 'something' for example???? Thanks On 16 abr, 15:35, mdipierro <mdipie...@cs.depaul.edu> wrote: > There is not such function. > > I think by > > if change_user_data(user): > > he actually means > > if user is allowed change do what he is trying to do: > > depending on the logicl you may not need this if statement at all. > > Massimo > > On Apr 16, 6:55 am, salbefe <salb...@gmail.com> wrote: > > > Hello, > > > I have a SQLFORM.factory form that I need to prepopulate with some > > data from a database. > > > id_nodo = request.args(0) > > > ## I get the data from the database > > nodo = db(db.node.id==id_nodo).select().first() > > detalle = db(db.node_details.node_id==id_nodo).select().first() > > > ##Now I need to prepolutate the fields title and body that I get from > > the database > > ## title = nodo.title, body = detalle.body > > form = SQLFORM.factory(db.node.title,db.node_details.body) > > if form.accepts(request.vars,session): > > > response.flash='Form accepted' > > > return dict(form=form) > > > As I read on this > > threadhttp://groups.google.es/group/web2py/browse_thread/thread/e2301b5cc3a... > > somebody with the same problem as me did the following: > > > user = db((db.user.id == req_user_id) & (db.addr.user == > > req_user_id)).select()[0] > > > db.user.id.default = user.user.id > > db.user.name.default = user.user.name > > db.user.email.default = user.user.email > > db.addr.city.default = user.addr.city > > > form = > > SQLFORM.factory(db.user.name,db.user.rname,db.addr.city) > > > if form.accepts(request.vars, session): > > > # change the user data > > if change_user_data(user): > > user.user.update_record(name=form.vars.name) # <---- > > user.addr.update_record(city=form.vars.city) # <---- > > response.flash = 'form accepted' > > else: > > response.flash = 'form not accepted' > > redirect(URL(r=request,f='index')) > > > I do not understand "if change_user_data(user):" > > > I have tried : > > > db.node.title.default = nodo.title > > db.node_details.body = detalle.body > > form = SQLFORM.factory(db.node.title,db.node_details.body) > > if form.accepts(request.vars,session): > > if change_node_data(node): > > ....................................... > > ...................................... > > > but I get an execption ('global name change_node_data is not defined'. > > Could anyone tell me how can I prepolutate the SQLFORM.factory form??? > > > Why is the function change_user_data used in that example if is not > > defined ???? > > > Thanks in advance > > > -- > > Subscription settings:http://groups.google.com/group/web2py/subscribe?hl=en