This is the default markup generated by web.form:
<tr><th><label for="X">Description</label></th><td><input id="X" ...
></td></tr>
Sometimes, however, a little more flexibility is needed. Like having
the <label> in its own row.
I'd like to suggest a modified form.render method.
def render(self, table=True):
out = []
out.append(self.rendernote(self.note))
if table:
out.append('<table>\n')
for i in self.inputs:
if table:
out.append('<tr><th>')
out.append('<label for="%s">%s</label>' % (i.id,
net.websafe(i.description)))
if table:
out.append('</th><td>')
out.append(i.pre+i.render()+i.post)
if table:
out.append('</td></tr>\n')
else:
out.append('\n')
if table:
out.append('</table>')
return ''.join(out)
That way, you can just call form.render() and get the default output
or form.render(table=False) to get the tableless version.
>>> form.render()
<tr><th><label for="X">Description</label></th><td><input id="X" ...
></td></tr>
>>> form.render(table=False)
<label for="X">Description</label><input id="X" ... >
Thoughts?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---