a, i understood now, thank you so much for detail explaination, anthony.
thanks and best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
By default, .validate doesn't do a database insert (which is why you have
manually done the insert yourself after calling .validate), so obviously
there will be no form.vars.id at the point that the onsuccess callback is
called. If you need the id available in the callback, then either use
.pro
why the result in form.process and in form.validate is different?
e.g.
*modules/test_event.py*
def oncreate_event(form):
current.db.auth_event.insert(time_stamp = current.request.now, client_ip =
current.request.client,
user_id = current.auth.user_id, origin = '%s/%s' %
(current.request.contro
yes, i know it's lack of parenthesis, pardon me, actually, my real code is
i put it on module n pass into variable via the controller, the test (app n
function), is the minimum application that was for dev environment to trace
back the root cause of the problem. btw, anthony has shown the way, t
are you aware that you are not calling the function ? or is that semicode.
def test():
form = SQLFORM(db.test)
if form.process().accepted:
oncreate_event () <- you lack the parenthesis here, and the argument
return dict(form = form)
On Saturday, April 4, 2015 at 10:51:02 PM UTC-5
There's no reason you can't use a function in your first example:
if form.process().accepted:
oncreate_event(form)
You can also use the "onsuccess" argument:
form.process(onsuccess=oncreate_event)
The above will mainly be useful when you have also specified a "next"
argument and need to do
pardon me, i mean is i would like to have something like oncreate in
SQLFORM.grid using SQLFORM.
so i think if i have more than a function to record the activity of user
input using SQLFORM, it will efficient to put it on the function, so that
another function can use my custom oncreate function
What do you mean by "call a function from form.process"? At what point do
you want to call a function? If you want to call a function if the form is
accepted, then your first example is the way to do it. If you would instead
like to call a function upon validation, but before further processing
8 matches
Mail list logo