> Can you provide an example of the API you would like to have? A small subset of the formal DOM API (http://www.w3.org/TR/DOM-Level-2- HTML/html.html) would do wonders:
* Top of the list would be "structural manipulation" functions that would allow insertion or removal of elements at specific places in the tree: appendChild(node), insertBefore(node), removeChild(node) . * Second would be "structural navigation", parentNode, .childNodes (see http://krook.org/jsdom/Node.html) * Search functions (a bit of a luxury given that we have form.element ()?): getElementByID(string elementId) and getElementsByTagName(string tagname) (http://krook.org/jsdom/Document.html) * And manipulation of "html nodes": getAttribute(), setAttribute(), removeAttribute() (http://krook.org/jsdom/Element.html) Of course, if I were half a man I would build it myself and send you a patch for html.py, but I'm afraid I am lacking both in experience and in time... ;-) Cheers, -Peter On Jan 19, 3:34 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > At this time using [i], .element, .append and .insert are the only > methods to manipulate the form. Can you provide an example of the API > you would like to have? > > Massimo > > On Jan 18, 2:54 pm, Peter <peter.kleyn...@gmail.com> wrote: > > > Hi Massimo et al, > > > First of all, the onvalidation callback that is now in SQLFORM (in > > trunk) is a real winner, thanks! The validation rules in my app are > > largely context-sensitive, and that was a big problem -- until now. > > > I am still struggling to find the best way to customize SQLFORM views, > > though. The "new" form.element() function only allows me to modify the > > attributes existing xml nodes -- is that correct? > > > For instance, I needed previous/next buttons in a multi-page form, and > > I really hate having to handcode entire forms in the html (or in the > > controller, for that matter). This is what I came up with: > > > # controller > > form=SQLFORM(db.t2_person,myperson,deletable=False,showid=False) > > > l = len(form.components[0]) # =number of rows in form > > > # add input element to second td in submit row > > form.components[0][l-1][1].append( INPUT(_type="buttonx") ) > > > # redefine both "submit" and "buttonx" > > form.element(_type="submit").update(_type="button", > > _value="<<Previous",_onclick="location='"+URL > > (r=request,f='step1')+"';") > > form.element(_type="buttonx").update(_type="submit", > > _value="Next>>") > > > Basically, I add a new 'dummy' input element and then redefine both > > inputs using form.element(). This works, but the direct use of the > > internal form/div structure to insert a new xml node is an eyesore. Is > > there a better way to do this? > > > Ideally, I'd be looking for a sort of formalized API that I could use > > to manipulate the entire xml tree of the form, eg, similar to the > > DOM. > > > Cheers, > > -Peter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---