I almost always use forms in this following way:

################################################

*#Create a DIV to WRAP it all*
>>> div = DIV(FORM())
>>> print div
<div><form action="" enctype="multipart/form-data"
method="post"></form></div>

*#Take the elements of the wrapper using DOM*
>>> print div.element('form')
<form action="" enctype="multipart/form-data" method="post"></form>

*#Create some other objects*
>>> table = TABLE()
>>> table.append(TR(TD(INPUT(_type='text',requires=IS_NOT_EMPTY()))))
>>> print table
<table><tr><td><input type="text" /></td></tr></table>

*#Append other objects to the wrapper*
>>> div.element('form').append(table)
>>> print div
<div><form action="" enctype="multipart/form-data"
method="post"><table><tr><td><input type="text"
/></td></tr></table></form></div>

*#validators works well*
>>> div.element('form').element(_type='text')['requires']
<gluon.validators.IS_NOT_EMPTY object at 0xa370f0c>

################################################


Note that it will work even if you want to use SQLFORM.

--
Bruno Rocha
http://about.me/rochacbruno/bio

Reply via email to