[web2py] Re: onvalidation in SQLFORM.grid (V2.0.9)

2012-09-14 Thread Gerd
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"
>  , 
> line 92, in 
>   File "/home/gniemetz/webapps/web2py/web2py/gluon/globals.py", line 186, in 
> 
> 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"
>  , 
> 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 
> .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 
> .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
>
>
>

-- 





[web2py] Re: onvalidation in SQLFORM.grid (V2.0.9)

2012-09-14 Thread 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"
>>  , 
>> line 92, in 
>>   File "/home/gniemetz/webapps/web2py/web2py/gluon/globals.py", line 186, in 
>> 
>> 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"
>>  , 
>> 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 
>> .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 
>> .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
>>
>>
>>

-- 





[web2py] Re: onvalidation in SQLFORM.grid (V2.0.9)

2012-09-14 Thread Gerd
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"
>>>  
>>> , 
>>> line 92, in 
>>>   File "/home/gniemetz/webapps/web2py/web2py/gluon/globals.py", line 186, 
>>> in 
>>> 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"
>>>  
>>> , 
>>> 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 
>>> .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 
>>> .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
>>>
>>>
>>>

-- 





[web2py] Re: onvalidation in SQLFORM.grid (V2.0.9)

2013-04-25 Thread Martín Miranda
Hiding  errors in SQLFORM.grid?

for example:
form = SQLFORM(db.table):
if form.accepts(request.vars, hideerror=True):
   

In SQLFORM.grid?

El viernes, 14 de septiembre de 2012 08:25:45 UTC-3, Gerd escribió:
>
> 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"
>  , 
> line 92, in 
>   File "/home/gniemetz/webapps/web2py/web2py/gluon/globals.py", line 186, in 
> 
> 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"
>  , 
> 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 
> .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 
> .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
>
>
>

-- 

--- 
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.