I am working on a very form-heavy website that uses not only labels, controls, and comments, it needs extended mouseover help as well. The users comprises people who use the site infrequently, so I need to provide as much explanation for each field as I possibly can. The nice thing about the mouseover help is that I can create a small [?] icon somewhere on each field line which pops up paragraphs of help text if needed. The question is -- where to store it?
Looking at Field, it seems like the ideal case would be to add an instance var "help" which could be initialized to "None". When needed, it could store some kind of "rich" string (which can have some simple formatting like bold face or italics for emphasis). While setting it in the Field is convenient, looking further at how the SQLFORM is generated from the Fields shows a real problem... The SQLFORM creates a list of 4-tuples which are passed to the "formstyle" factory that makes the HTML version of the form. There's no way I can add a 5th element to the tuple without breaking web2py. If we someday re-architect the web2py SQLFORM class, we might consider passing in a list of the Field objects directly to the formstyle factory so we never face this limit again. But for now I don't see any way to overcome this. All I can come up with is to generate the HTML tree for the form (in Python) and then use the access methods to manipulate it to add the help elements I want. It will be kind of messy and complicated but I can probably get it working. Or maybe I should do my own "formstyle" function and figure out a way to pass it a list of "help" text fields for the additional info. If anyone else has done something similar I'd love to hear about it. Joe B. --