Thanks Anthony for your reply.

Greetings
Adam

W dniu środa, 18 maja 2016 14:15:00 UTC+2 użytkownik Anthony napisał:
>
> On Wednesday, May 18, 2016 at 6:22:50 AM UTC-4, Adam Drzewiecki wrote:
>>
>> Hi everybody,
>>
>> I have some problem with my search_widget.
>> I would like to create search_widget with less fields, but i get 
>> error: <type 'exceptions.AttributeError'> 'str' object has no attribute 
>> 'get'
>>
>> My code:
>> search_options = {'string': ['=', '!=', '<', '>', '<=', '>=', 'starts 
>> with', 'contains', 'in', 'not in']}
>>  fields = [db.clients.host_name, db.clients.current_project]
>>  update_grid = SQLFORM.grid(db.clients, (db.clients.host_name, db.clients
>> .current_project),searchable=True, search_widget=lambda fields, 
>> search_options: SQLFORM.search_menu(fields, search_options)....
>>
>
> You are confusing search_widget and the search menu (the former is the 
> form in which you enter and submit keywords, and the latter is a menu of 
> search operators that can be used within the widget). The search_widget 
> argument is a function that takes a fields argument and a url argument. So, 
> what you are expecting as the search_options argument is just a URL. Also, 
> note that the grid passes the arguments to the search_widget function, so 
> it does nothing for you to define your own search_options dictionary 
> without also somehow passing it to the search_menu method yourself.
>
> Instead, you probably want something like this:
>
> search_widget=lambda fields, url, search_options=search_options: CAT(FORM
> (..., _action=url),
>     SQLFORM.search_menu(fields, search_options))
>
> In short, there is no way to customize only the search menu without 
> creating an entire custom search_widget.
>
> Anthony
>

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