SOLVED:

sf.requires = IS_IN_DB( db(query), db.*other_*table.*_id* , 
label=other_table._format,  left=left, distinct=True )

instead of

sf.requires = IS_IN_DB( db(query), db.table.*other_id* , 
label=other_table._format,  left=left, distinct=True )

:)

On Friday, January 13, 2017 at 11:13:10 AM UTC+2, Jurgis Pralgauskis wrote:
>
>
>
> Hi, 
>
> I have query  to get subset of stuff (and I want to have the same nice 
> options widget as is for default foreign keys)
>
> sf.requires = IS_IN_DB( db(query), db.table.other_id , 
> label=other_table._format,  left=left, distinct=True )
>
>
> but I get
>
>     form = SQLFORM.factory( *updatables, table_name="jurgio")
>   File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 1809, in factory
>     **attributes)
>   File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 1286, in __init__
>     inp = field.widget(field, default)
>   File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 388, in widget
>     options = requires[0].options()
>   File "/home/jurgis/dev/web2py_src/gluon/validators.py", line 598, in options
>     self.build_set()
>   File "/home/jurgis/dev/web2py_src/gluon/validators.py", line 573, in 
> build_set
>     fields = [table[k] for k in self.fieldnames]
>   File "/home/jurgis/dev/web2py_src/gluon/packages/dal/pydal/objects.py", 
> line 510, in __getitem__
>     raise KeyError(key)
> KeyError: 'role'
>
>
>
> I could do select myself and construct IS_IN_SET -- but how can I fluently 
> get all the fields needed for   foreign _format (if  _format  varies 
> depending on other_table)? 
>
> any suggestions?
>
> Thanks
>

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