It is because of mechanism to prevent double form submission. It
breaks with multiple forms/age. To avoid this problem replace:

if form.accepts(request.vars, session):

with

if form.accepts(request.vars):

Massimo

On Sep 7, 4:31 pm, Alastair Medford <alastairmedf...@gmail.com> wrote:
> Currently I am displaying multiple forms on one page via iframes, each
> calling the same controller. When only one form is displayed on the
> page, the form submits properly and validates etc. When two forms are
> displayed however, pressing submit merely refreshes the iframe. When I
> hit submit a second time, then the form acts as it should. It's like
> the form has to be "warmed up" before submitting. I imagine this has
> something to do with how the hidden form fields like formkey and named
> are stored in the session and checked later, but I do not understand
> how they work enough to resolve this. Any ideas? The code for the form
> controller and the controller that builds and displays the iframes is
> below.
>
> #controller of form displayed in the iframe
> def buildPage():
>     content = []
>     appname = request.application
>     data = xmltools.getData(request.vars.code, appname)
>     template = xmltools.getTemplate(data.tag, appname)
>     for i in template:
>         if i.tag == "header":
>             content.append(H1(i.text))
>         elif i.tag == "label":
>             content.append(P(i.text))
>         elif i.tag == "database":
>             form = SQLFORM(db[i.text])
>             form.vars.form_id = request.vars.code
>             #form.vars.time = dt.datetime.now().strftime("%Y-%m-%d %H:
> %M:%S")
>             if form.accepts(request.vars, session):
>                 response.flash='New Page entered'
>             elif form.errors:
>                 response.flash='Check form for errors'
>             content.append(form)
>         else:
>             el = xmltools.findElement(data, name=i.tag)
>             if el is not None:
>                 for j in el:
>                     if j.tag == 'bulk_text':
>                         text = xmltools.parseBulk(j)
>                         for k in text:
>                             content.extend([k, BR()])
>                     elif j.tag == 'bulk_checkbox':
>                         text = xmltools.parseBulk(j)
>                         for k in text:
>                             content.extend([INPUT
> (_type='checkbox'),k,BR()])
>             else:
>                 content.append(i.tag)
>
>     return response.render('default/form.html',dict(page=DIV
> (*content)))
>
> #code of the controller that builds and displays the iframes
> def buildTabs():
>     if session.tabs is None:
>         session.tabs = []
>     if session.tabNames is None:
>         session.tabNames = 0
>     #if request.vars.code is not None:
>     name = session.tabNames
>     session.tabNames += 1
>     frame = IFRAME(_width='100%', _height='500px', _src=URL
> (r=request,f='buildPage',vars=request.vars))
>     tab = DIV(frame, A('close', _href='#', _class='close'),
> _name=name, _class='tab')
>     session.tabs.append({'tab':tab, 'name':name,
> 'form':request.vars.code})
>     content = DIV(_id = 'tabCont')
>     tabmenu = UL(_id='tabMenu')
>     content.append(tabmenu)
>     for i in session.tabs:
>         tabmenu.append(LI(A(i['form'], _href='#'), _name=i['name']))
>         content.append(i['tab'])
>     return content
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to