Hi Niphlod, I studied your example, but can't quite get it to work yet. I also tried taking a look at your view but it's to complicated for me. The only issue I'm having now is that the key isn't incrementing from the view side. Can I pass the key in the view like {{=form+key}} or something? Maybe I'm screwing up my controller.
controller: def show_form(): users_1 = db(db.people.id.belongs(session.people.keys())).select(db.people.user_id) users_2=[] for user in users_1: if user not in users_2: users_2.append(user) else: pass for user in users_2: usr= db(db.auth_user.id==user.user_id).select(db.auth_user.username,db.auth_user.id)[0] usr1=usr.username usr2=usr.id key=str(usr2) fields = [ Field('username',default=usr1,writable=False) ] form=SQLFORM.factory(*fields, table_name=key,hidden=dict(ss_id=key)) return dict(form=form, users_2=users_2,usr1=usr1,usr2=usr2,key=key) View: {{extend 'layout.html'}} <h1>Form:</h1> {{for user in users_2:}} {{=form}} {{pass}} <!-- returns a form for each user but uses the same key for every form; result is that the default value is the same for every form--> <h1> custom form: </h1> {{=form.custom.begin}} {{for user in users_2:}} User: {{=form.custom.widget.user}}<br> {{pass}} {{form.custom.end}} <!-- returns a form for each user but uses the same key for every form; result is that the default value is the same for every form--> <h1> manual form: gives the correct results </h1> {{for user in users_2:}} {{ usr= db(db.auth_user.id==user.user_id).select(db.auth_user.username,db.auth_user.id)[0] usr1=usr.username usr2=usr.id key=str(usr2) }} KEY:{{=key}}<br> <!-- here to check that the key changes correctly --> <form action="#" enctype="multipart/form-data" method="post"><table><tr id="{{=key}}_user__row"><td class="w2p_fl"><label for="{{=key}}_user" id="{{=key}}_user__label">username: </label></td><td class="w2p_fw">{{=usr1}}</td><td class="w2p_fc"></td></tr><tr id="submit_record__row"><td class="w2p_fl"></td><td class="w2p_fw"><input type="submit" value="Submit" /></td><td class="w2p_fc"></td></tr></table><div style="display:none;"><input name="ss_id" type="hidden" value="{{=key}}" /></div></form> {{pass}} I prefer to use the {{form.custom.widget[Field]}} tags. Can you tell me what I'm doing wrong? On Tuesday, December 17, 2013 11:21:32 PM UTC+1, Niphlod wrote: > > you just need to figure out a "key" to separate different forms, and use > formname accordingly as stated in the book. > I do it in w2p_tvseries already, you can take a look at > https://github.com/niphlod/w2p_tvseries/blob/master/controllers/manage.py > specifically, see lines #169, #239 and #266 > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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.