Correction. {{=form.custom.labels[fieldname]}} did work in the trunk, but the proper syntax is "label", not "labels".
Sorry for the misinformation. On Jun 10, 9:58 pm, Gary <gary.k.ma...@gmail.com> wrote: > Massimo, > > Thank you. You mentioned before that widget worked in the trunk - you > are, of course correct, but I just wanted to make note to others that > it fails in the current version 1.63.5. Also, {{=form.custom.labels > [fieldname]}} did not work in the trunk. It failed with "TypeError: > 'NoneType' object is unsubscriptable". Just wanted you to know. > > Thanks again! > > On Jun 10, 5:59 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > On Jun 10, 3:49 pm, Gary <gary.k.ma...@gmail.com> wrote: > > > > Massimo, > > > > Thank you so much for your feedback. Most of the changes you > > > suggested certainly made the code simpler and easier to read, but I > > > have a couple of issues that I don't understand. > > > > 1) It appears that the line: > > > > getattr(crud,session.action)(db[tablename],record) > > > getattr(yyy,'xxx') is the same as yyy.xxx > > > > executes the crud call, but I don't understand how getattr() does > > > that. Could you provide a brief explanation? > > > > 2) If I directly return the dictionary that results from setsubmit > > > (tablename), what would the format of the return be and what should > > > the variables in the form be named? I tried a couple of combinations > > > (widgets, inpval, dspval) , but they all failed (widget) carried extra > > > data (impval) or failed to display an <input> on update. > > > You only need widgets > > > <form> > > {{=form.custom.widget.field1}} > > {{=form.custom.widget.field2}} > > {{=form.custom.widget.field3}} > > <input type="submit"> > > {{=form.hidden_fields()}} > > </form> > > > > 3) In thefields(), the value of curform is: > > > > <form action="" enctype="multipart/form-data" method="post"><table><tr > > > id="location_poleno__row"><td><label for="location_poleno" > > > id="location_poleno__label">Poleno: </label></td><td>EBW 1234</ > > > td><td></td></tr><tr id="location_town_id__row"><td><label > > > for="location_town_id" id="location_town_id__label">Town Id: </label></ > > > td><td>1</td><td></td></tr> ..... > > > > and curform.record is: > > > > <SQLStorage {'electricprovider': None, 'update_record': <function > > > <lambda> at 0x9ff80d4>, 'npolesize': None, 'notifydate': > > > datetime.datetime(2009, 3, 27, 8, 9, 43), 'id': 2, > > > 'specialprotection': None, 'city': 'East Brunswick', 'data1': None, > > > 'zipcode': '08816', 'cableprovider': None, 'state': 'NJ', 'town_id': > > > 1, .... > > > > Please notice that in both places, the value of town_id is 1 and not > > > the value in the related table. > > > > When I set mydict = dict(form=curform) is was able to fix a syntax > > > error 'mydict does not exist' but I'm not sure that's the right thing > > > to do. However, the real problem is an error message that says > > > curform.custom.widget is not iterable. Even if it fixes it, I'm still > > > not sure what the variables in the form should be named. > > > I think you can do: > > > {{for fieldname in form.custom.widget:}} > > <label>{{=form.custom.labels[fieldname]}}</label>{{=form.custom.widget > > [fieldname]}} > > {{pass}} > > > I do not think you need thefields since it only provides info that is > > alredy in the form. > > > Not sure if this helps. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---