class "Form" allows to add fields only one per line. Therefore, we
have the following scenario:

>>> print(form.Form(form.Textbox('text_1'),form.Button('button_1'),form.Textbox('text_2'),form.Button('button_2')).render())
<table>
    <tr><th><label for="text_1">text_1</label></th><td><input
type="text" name="text_1" id="text_1" /></td></tr>
    <tr><th><label for="button_1"></label></th><td><button
name="button_1" id="button_1">button_1</button></td></tr>
    <tr><th><label for="text_2">text_2</label></th><td><input
type="text" name="text_2" id="text_2" /></td></tr>
    <tr><th><label for="button_2"></label></th><td><button
name="button_2" id="button_2">button_2</button></td></tr>
</table>
but I want to get this:
<table>
    <tr>
        <th><label for="text_1">text_1</label></th><td><input
type="text" name="text_1" id="text_1" /></td>
        <th><label for="button_1"></label></th><td><button
name="button_1" id="button_1">button_1</button></td>
    </tr>
    <tr>
        <th><label for="text_2">text_2</label></th><td><input
type="text" name="text_2" id="text_2" /></td>
        <th><label for="button_2"></label></th><td><button
name="button_2" id="button_2">button_2</button></td>
    </tr>
</table>
How to implement this standard means I have not found. Perhaps they
are, but I do not find these ways. In this case, please tell me the
standard way of solutions. However, I decided to try to create ьн
analog "form.Form" with the following syntax:
Form ( (str1_pos1, str1_pos2, ..., str1_posN), ( str2_pos1, ...), ...,
(strM_pos1, strM_pos2) )
I'm working on it. At this moment, I did this:
class MyForm(Form):
    def render(self):
        def recursiverender(i):
            if isrecursive(i):
                raise ## возможно лучше return ""
            if type(i) in [list, tuple]:
                return "    <tr>%s</tr>\n"%reduce(lambda x,y:x+y,
[recursiverender(ii) for ii in i])
            else:
                return '<th><label for="%s">%s</label></th><td>%s</
td>' % (i.id, net.websafe(i.description),i.pre+i.render()+i.post)
        return '%s<table>\n%s</table>' % (
            self.rendernote(self.note),reduce(lambda x,y:x+y,
                [type(i)==tuple and recursiverender(i) or
recursiverender((i,)) for i in self.inputs]) )

As a result:
>>> print(form.MyForm((form.Textbox('text_1'),form.Button('button_1')),(form.Textbox('text_2'),form.Button('button_2'))).render())
<table>
    <tr><th><label for="text_1">text_1</label></th><td><input
type="text" name="text_1" id="text_1" /></td><th><label
for="button_1"></label></th><td><button name="button_1"
id="button_1">button_1</button></td></tr>
    <tr><th><label for="text_2">text_2</label></th><td><input
type="text" name="text_2" id="text_2" /></td><th><label
for="button_2"></label></th><td><button name="button_2"
id="button_2">button_2</button></td></tr>
</table>

But this is only one class method. I hope my ideas in the future, fall
into the mainstream. I will be glad of any assistance.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to