Sorry, forgot that you have to extract the form from the grid object. You 
can also get the create and update forms via:

form = grid.element('.web2py_form')

Note, that will be None if there is no form (e.g., when loading just the 
grid), so first test that it exists.

Anthony

On Tuesday, July 22, 2014 2:46:59 AM UTC-4, Massimo Di Pierro wrote:
>
> you say form = SQLFORM.grid(....) but this is not a form, this is a grid 
> even if you call it form. Therefore there is no form.process(), there is no 
> form.accepted, there is no form.errors etc. This if not a form.
>
> A grid MAY contain a form so you should do:
>
> grid = SQLFORM.grid()
> if grid.create_form:
>      if grid.create_form.errors:
>            ....
> elif grid.update_form:
>      if grid.update_form.errors:
>            ...
>
> NEVER call process() for these forms. The grid process them automatically 
> and you should never process() twice.
>
> On Tuesday, 22 July 2014 01:35:07 UTC-5, Yebach wrote:
>>
>> Looks like everything I do with form.* after I declare it in my 
>> controller I get an error
>>
>> What am I doing wrong here?
>>
>>
>> 2014-07-22 8:15 GMT+02:00 Vid Ogris <vid.og...@gmail.com>:
>>
>>> If I use 
>>> if form.accepted:
>>>
>>> I still get an error 
>>> <type 'exceptions.AttributeError'> 'DIV' object has no attribute 
>>> 'accepted'
>>>
>>> I put <div class="flash">{{=response.flash}}</div> in my view
>>>
>>>
>>> 2014-07-21 16:05 GMT+02:00 Anthony <abasta...@gmail.com>:
>>>
>>> The message is in response.flash, so you need to display that in your 
>>>> view somewhere (it is already present in the layout.html of the 
>>>> scaffolding 
>>>> app).
>>>>
>>>> Anthony
>>>>
>>>>
>>>> On Monday, July 21, 2014 8:23:16 AM UTC-4, Yebach wrote:
>>>>>
>>>>> Thank you on fast reply
>>>>>
>>>>> How do I present this message in my view?
>>>>>
>>>>>
>>>>> 2014-07-21 14:13 GMT+02:00 Anthony <abasta...@gmail.com>:
>>>>>
>>>>>> Do not call the .process method on a grid -- it automatically does 
>>>>>> the processing itself. If you don't like the default flash messages, you 
>>>>>> can do:
>>>>>>
>>>>>> if form.accepted:
>>>>>>
>>>>>> or:
>>>>>>
>>>>>> SQLFORM.grid(..., formargs=dict(message_onsuccess='form accepted',
>>>>>>                                 message_onfailure='form has errors'))
>>>>>>
>>>>>>
>>>>>> Anthony
>>>>>>
>>>>>>
>>>>>> On Monday, July 21, 2014 6:43:00 AM UTC-4, Yebach wrote:
>>>>>>>
>>>>>>> Hello
>>>>>>>
>>>>>>> I have a SQLForm.grid. 
>>>>>>>
>>>>>>> I want to create a response.flash message but on my if evaluation I 
>>>>>>> get an error when my edit view is done
>>>>>>>
>>>>>>> <type 'exceptions.AttributeError'> 'DIV' object has no attribute 
>>>>>>> 'process'
>>>>>>> even on my sqlform.grid view
>>>>>>>
>>>>>>> this is my controller function
>>>>>>>
>>>>>>>          form = SQLFORM.grid(query=query, 
>>>>>>> left=db.status.on(db.worker.w_status == db.status.id),
>>>>>>>  fields=fields,  searchable=True, orderby=default_sort_order,cre
>>>>>>> ate=True,
>>>>>>> deletable=True, editable=True, paginate=25, buttons_placement = 
>>>>>>> 'right')
>>>>>>>   if form.process().accepted:
>>>>>>>  response.flash = 'form accepted'
>>>>>>>  elif form.errors:
>>>>>>>  response.flash = 'form has errors'
>>>>>>> else:
>>>>>>> response.flash = 'please fill the form'
>>>>>>>     # Note: no form instance is passed to the view
>>>>>>>  return dict(form=form)
>>>>>>>
>>>>>>>  -- 
>>>>>> 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 a topic in 
>>>>>> the Google Groups "web2py-users" group.
>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>>>>> topic/web2py/2ikYrc84qB4/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to 
>>>>>> web2py+unsubscr...@googlegroups.com.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Lep pozdrav 
>>>>>
>>>>> Vid Ogris
>>>>>
>>>>>
>>>>>   -- 
>>>> 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 a topic in the 
>>>> Google Groups "web2py-users" group.
>>>> To unsubscribe from this topic, visit 
>>>> https://groups.google.com/d/topic/web2py/2ikYrc84qB4/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to 
>>>> web2py+unsubscr...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Lep pozdrav 
>>>
>>> Vid Ogris
>>>
>>>
>>>  
>>
>>
>> -- 
>> Lep pozdrav 
>>
>> Vid Ogris
>>
>>
>>  

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

Reply via email to