Thanks for your help Massimo Am Freitag, 14. September 2012 16:08:14 UTC+2 schrieb Massimo Di Pierro: > > Hello Gerd, the grid is a grid. It is not a form (although it may contain > forms) therefore it does not have a grid.errors. Embedding into a form does > not solve the problem. > > Yet you can check if the grid contains a form and whet the errors for that > form are: > > if grid.create_form and grid.create_form.errors: > .... > if grid.update_form and grid.update_form.errors: > .... > > > > On Friday, 14 September 2012 06:58:19 UTC-5, Gerd wrote: >> >> Hi again! >> >> I found it, the right way is >> >> if FORM(grid).errors: >> >> >> but unfortunately the response.flash gets not set, it has always the >> value "Errors in form, please check it out". I tried to set it in index and >> in check_km with no luck >> >> Has someone a good idea? >> >> Regards >> Gerd >> >> >> Am Freitag, 14. September 2012 13:25:45 UTC+2 schrieb Gerd: >>> >>> Hi! >>> >>> I receive the following error >>> >>> Traceback (most recent call last): >>> File "/home/gniemetz/webapps/web2py/web2py/gluon/restricted.py", line >>> 209, in restricted >>> exec ccode in environment >>> File >>> "/home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py" >>> >>> <https://tauchbuch.niemetz.it/admin/edit/tauchbuch/controllers/default.py>, >>> line 92, in <module> >>> File "/home/gniemetz/webapps/web2py/web2py/gluon/globals.py", line 186, >>> in <lambda> >>> self._caller = lambda f: f() >>> File "/home/gniemetz/webapps/web2py/web2py/gluon/tools.py", line 2809, in >>> f >>> return action(*a, **b) >>> File >>> "/home/gniemetz/webapps/web2py/web2py/applications/tauchbuch/controllers/default.py" >>> >>> <https://tauchbuch.niemetz.it/admin/edit/tauchbuch/controllers/default.py>, >>> line 16, in index >>> if grid.errors: >>> AttributeError: 'DIV' object has no attribute 'errors' >>> >>> >>> >>> This is the controller >>> >>> @auth.requires_login() >>> def index(): >>> grid = SQLFORM >>> <https://web2py.niemetz.it/examples/global/vars/SQLFORM>.grid(db.Logbuch,fields=[db.Logbuch.Datum,db.Logbuch.Kurs,db.Logbuch.Thema,db.Logbuch.Kommentar],maxtextlength=50,orderby=[~db.Logbuch.Datum],onvalidation=check_km) >>> if grid.errors: >>> response >>> <https://web2py.niemetz.it/examples/global/vars/response>.flash = 'Bitte >>> Eingaben überprüfen' >>> return locals() >>> >>> def check_km(form): >>> if form.vars.KM_Beginn >= form.vars.KM_Ende: >>> form.errors.KM_Ende = 'KM-Stand Ende kleiner/gleich KM-Stand Beginn' >>> >>> >>> What i'm trying to do is to set response.flash >>> >>> What am i doing wrong here? >>> >>> Thanks, >>> regards >>> Gerd >>> >>> >>>
--

