No, in this case, the "c" field is neither readable nor writable, so it won't appear in forms (including readonly forms) or the grid unless explicitly added. The code in question calculates and inserts a value for "c" based on the values for "a" and "b", but this is not displayed anywhere.
Anthony On Thursday, May 28, 2015 at 1:16:53 AM UTC-4, chaitanya wrote: > > Hi Iam very new to web2py. > According to my understanding, if the c value is greater than zero the c > value has to be displayed. > I used the same code as yours but I did not see the c value printed. > Can you please clarify if Iam understanding it wrong. > > On Friday, December 23, 2011 at 3:13:04 PM UTC-6, Massimo Di Pierro wrote: >> >> onvalidation = my_form_processing >> >> registers a callback (called after validation and before accepting). >> This does not work >> >> def my_form_processing(table_name, form): form.vars.field1 = >> table_name # I know useless, it just >> >> because the callback function must take a single parameter, the form. >> You can do instead >> >> def my_form_processing(form): >> form.vars.field1 = form.table.name # I know useless, it just >> >> Hope this helps. >> >> >> On Dec 23, 1:32 pm, Richard <ml.richard.vez...@gmail.com> wrote: >> > Hello, >> > >> > In the book there is this example : >> > >> > db.define_table('numbers', >> > Field('a', 'integer'), >> > Field('b', 'integer'), >> > Field('c', 'integer', readable=False, writable=False)) >> > >> > def my_form_processing(form): >> > c = form.vars.a * form.vars.b >> > if c < 0: >> > form.errors.b = 'a*b cannot be negative' >> > else: >> > form.vars.c = c >> > >> > def insert_numbers(): >> > form = SQLFORM(db.numbers) >> > if form.process(onvalidation=my_form_processing).accepted: >> > session.flash = 'record inserted' >> > redirect(URL()) >> > return dict(form=form) >> > >> > Where "my_form_processing" function is called without bracket and >> > arguments... >> > >> > I try to do this that failed : >> > >> > def my_form_processing(table_name, form): >> > form.vars.field1 = table_name # I know useless, it just >> > demonstration for purpose of my question... >> > >> > ... >> > >> > if form.process(onvalidation=my_form_processing(request.args(0), >> > form)).accepted: >> > >> > Then I did : >> > >> > def my_form_processing(form): >> > form.vars.field1 = request.args(0) >> > >> > ... >> > >> > if form.process(onvalidation=my_form_processing).accepted: >> > >> > That actually works... >> > >> > I would like to make sure that I understand onvalidation properly... >> > >> > Is "my_form_processing" just a extension of the "insert_numbers()" >> > function? >> > >> > And if so, does it have access to all the same variables >> > (environnement) of "inser_numbers()"?? >> > >> > Thank you! >> > >> > Richard > > -- 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) --- 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/d/optout.