I'm using the onvalidation argument as a dict to pass a function for 
onsuccess and onfailure. e.g.
if form.accepts(request.vars, formname='client_form', onvalidation=dict(
onsuccess=validateClientForm, onfailure=validateClientForm)):

The problem is that if onfailure is given as an argument and the url 
contains a request parameter the form is always validated and not just when 
it is submitted. 

I currently use this workaround:
request_vars = Storage()
if request.vars._formname:
  request_vars = request.vars

 if form.accepts(request_vars, formname='client_form', onvalidation=dict(
onsuccess=validateClientForm, onfailure=validateClientForm)): 



If there are no request parameters the method works fine. I assume the bug 
is in html.py line 2012 (although I don't think I fully understood the 
code):
if onfailure and request_vars and not status:

I think it should not only check if there are request parameters but also 
if the form was actually submitted (this is automatically done for 
onsuccess because status is only True if the form was submitted). I assume 
this should work:
if onfailure and request_vars and  formname == request_vars._formname and 
not status:

This bug already exists for a long time (at least since 1.99.2). Is there 
any chance it gets fixed?

thanks,
Alex

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to