[web2py] Re: One AutoComplete overrides another

2014-12-22 Thread tim . nyborg
Found my mistake; hopefully it will save someone time in the future.

Multiple autocompletes referring to the same field need keyword arguments, 
otherwise they all end up as the 
default '_autocomplete_%(tablename)s_%(fieldname)s' 
(_autocomplete_module_code in my case).  Once I gave them distinct names, 
everything worked.

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


[web2py] Re: One AutoComplete overrides another

2014-12-22 Thread Tim Nyborg
I haven't found a solution to this, but have found more detail about the 
problem:

The first defined autocomplete widget on a particular field overrides ALL 
others defined after.

idb.define_table(
'fee',
   ...
Field('module_code', 'string', writable=False, label='Module code', 
  requires=IS_IN_DB(idb, idb.module.code, 
error_message='Required'), 
  widget=SQLFORM.widgets.autocomplete(request, idb.module.code, 
min_length=1),
  )
)

idb.define_table(
'tutor_module',
...
Field('module_code', 'string', writable=False, label='Module code', 
  requires=IS_IN_DB(idb, idb.module.code, 
error_message='Required'), 
  widget=SQLFORM.widgets.autocomplete(request, idb.module.code, 
id_field=idb.module.id,
  orderby=idb.module.code, 
min_length=2, 
  help_fields=[idb.module.code, 
idb.module.title],
  help_string='%(code)s - 
%(title)s'),   
  )
)



In this case, the second table's autocomplete widget always renders the way 
the first should (including the missing id_field).

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