Probably both forms have the same formname, either because they are both 
based on the same DAL table or because they are both SQLFORM.factory forms. 
To avoid the problem, assign unique formnames to each via 
.process(formname='myform1'), etc. This is discussed in the book: 
http://web2py.com/books/default/chapter/29/07#Multiple-forms-per-page.

Note, the problem isn't really limited to multiple forms on the same page, 
but to multiple forms with the same name in the same browser session (even 
if loaded into different tabs/windows that are open at the same time). The 
problem is that the value of the formkey is stored in the session with a 
key like "_formkey[formname]". If a second form is created before the first 
form has been submitted, the formkey associated with that particular 
formname will be overwritten, so when the first form is submitted, it will 
not be accepted. However, the submission itself will once again replace the 
formkey value, so if you immediately submit a second time, it will work.

Anthony

On Sunday, April 21, 2013 5:03:06 AM UTC-4, Neil wrote:
>
> I'm having this problem now - is there a trick to having two ajax forms on 
> one page?
>
> Basically, as above, I have to hit submit twice for anything result. Has 
> anyone successfully had 2+ ajax forms on the same page?
>
> On Wednesday, 21 July 2010 08:37:54 UTC+1, mdipierro wrote:
>>
>> will look into this.. it must be a JS issue. 
>>
>> On Jul 20, 9:10 pm, ionel <ionelanton...@gmail.com> wrote: 
>> > Hello, 
>> > 
>> > I try to add two ajax forms into a page with something like this: 
>> > 
>> > {{=LOAD(url=URL(r=request,f='add_person.load'), ajax=True)}} 
>> > {{=LOAD(url=URL(r=request,f='add_image.load'), ajax=True)}} 
>> > 
>> > If the form has errors, the error messages are displayed after a 
>> > second submit. So, I need to click two times the submit button to 
>> > display them. 
>> > 
>> > The second form has a normal behavior. 
>> > 
>> > Thanks. 
>> > 
>> > i.a.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to