Thanks for your inspiring answer, After I found this page: http://code.activestate.com/recipes/440502-a-dictionary-with-multiple-values-for-each-key/ ...I tried with: return dict['form'].append([x]) ...but my new code doesn't work neither. I just get "TypeError: 'type' object is unsubscriptable". Though I think this code is nearer the solution.
On Jul 12, 10:44 pm, JmiXIII <sylvn.p...@gmail.com> wrote: > 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 <sababa.sab...@gmail.com> 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