Hello ,
I've used something like this :
def listform():
listf=[]
thing = [one two three]
for x in thing:
form=FORM(':', INPUT(_name="name"))
listf.append(form)
return dict(listf=listf)
Yet I usually use SQLFORM and add a submit button
As this is my firts answer to a coding question, do not hesitate to
tell if I'm wrong
On 12 juil, 22:26, Rick <[email protected]> wrote:
> Hi,
>
> How to generate multiple forms with a loop?
>
> In my controller file there are forms generated with this loop:
>
> thing=[one, two, three]
> def theFunction():
> for thing1 in varibale1:
> form=FORM(':',
> INPUT(_name='name')
> )
> return dict(form=form)
>
> ...but this code doesn't work. I just get the message "invalid view".
> I suppose the reason that I get this message is that all the forms
> have the same name in the view file. Therefor I also tried with:
> return dict(form=[thing])
> ...but got:
> SyntaxError: keyword can't be an expression
>
> I've tried with this code in the view file:
>
> {{extend 'layout.html'}}
> <h2>{{=form}}</h2>
>
> ...and also with this:
>
> {{extend 'layout.html'}}
> <h2>
> {{thing=[one, two, three]}}
> {{for thing1 in varibale1:}}
> {{=form}}
> </h2>
>
> ...but none of them worked.
>
> Thanks in advance for help