SQLFORM.widgets.autocomplete
) but my field is a list:string, and now it shows all data in only one field, resulting in an awkward input. How can I use this widget with a list:string field? Thanks in advance. :)Hello! My issue is this: I want to use the autocomplete widget (SQLFORM.widgets.autocomplete
) but my field is a list:string, and now it shows all data in only one field, resulting in an awkward input. How can I use this widget with a list:string field? Thanks in advance. :)
db.define_table('company',
Field('name', 'string', length=20, represent=lambda name, row: name.capitalize(), required=True,
unique=True, notnull=True,
requires=[IS_NOT_EMPTY(error_message='You must enter a company name'),
IS_MATCH('^[a-zA-Z0-9][a-zA-Z0-9 ,-.]*$')
]),
Field('user_id', 'reference auth_user', ondelete='NO ACTION', label='User',
writable=False, readable=False,
),
Field('is_default', 'boolean', writable=False),
address,
format=lambda r: r.name or 'No name company')
db.company.name.requires = IS_NOT_IN_DB(db, db.company.name, error_message='This company name is in use')
db.company.country.widget=SQLFORM.widgets.autocomplete(request, COUNTRIES, limitby=(0,10), min_length=2)
<type 'exceptions.AttributeError'> 'tuple' object has no attribute 'tablename'
In fact that is the the problem. I want to fill the country widget with just a list (ordinary python list of strings) of countries so the user can select from that list.
So essentially the backing list of the auto complete isn't part of the db but just a bunch of strings in an ordinary list
--
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/6a4KRtDE26M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.