Thanks, Anthony.
because there may be MANY values in the field, what I would actually be
perfectly happy with is a list as you describe it,
but one that is the result of a db query,
e.g. a list of names of all schools whose "Field('district_id' ,
'reference districts', label=T('District')" is 2.
Tried doing that yesterday without success.
On Tuesday, June 19, 2018 at 4:05:08 AM UTC-7, Anthony wrote:
>
> No, as the example in the book shows, by "list", it just means a list
> generated from the contents of a single field in a database table (in
> contrast to the reference field option, which submits integer ID values
> from a reference field but searches and displays the corresponding values
> from an alternative field).
>
> There are other autocomplete widgets you can use, but if you really want
> to use the web2py widget, I suppose you could just put your list in a
> database table.
>
> Anthony
>
> On Monday, June 18, 2018 at 11:59:27 PM UTC-4, jim kaubisch wrote:
>>
>> What am I misunderstanding... ??
>>
>> Building a form with fields that really need to be autocompleted
>> (potentially 1,000+ possible values).
>>
>> Looked at the book which says "two possible uses for the autocomplete
>> widget: to autocomplete a field that takes a value from a *list* or to
>> autocomplete a *reference field*"
>> I assumed that "list" meant an ordinary Python list object, but when I
>> try:
>>
>> fields = []
>> ...
>>
>> name_list = ['name1', 'name2']
>> fields.append(Field('school', 'string' , label=T('School Name?')
>> ,
>> widget=SQLFORM.widgets.autocomplete(request , name_list, limitby=(0,10),
>> min_length=0)
>> , requires=IS_NOT_EMPTY()))
>> ...
>>
>> enter_data_form=SQLFORM.factory(*fields, table_name='enter_data')
>>
>> I get the following:
>> <type 'exceptions.AttributeError'> 'list' object has no
>> attribute 'tablename'
>>
>> which I interpret to mean that 'list' in this case means something
>> different than I expected.
>>
>> What am I doing wrong?
>>
>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.