The widget take as argument the table itself which is not yet defined. you have to do it in two steps:
db.define_table('doccenter', Field('doc_nr', type='string', length=50, requires=IS_NOT_IN_DB(db, 'doccenter.doc_nr'), ) db.doccenter.doc_nr.widget =SQLFORM.widgets.autocomplete( request, db.doccenter.doc_nr, limitby=(0,20),min_length=2, id_field=db.doccenter.id)) On May 9, 2:21 am, Johann Spies <johann.sp...@gmail.com> wrote: > I get a "KeyError: 'doccenter' " when I add an autocomplete widget in the > following situation: > > db.define_table('doccenter', > Field('doc_nr', type='string', length=50, > requires=IS_NOT_IN_DB(db, 'doccenter.doc_nr'), > widget =SQLFORM.widgets.autocomplete( > request, db.doccenter.doc_nr, limitby=(0,20), > min_length=2, > id_field=db.doccenter.id) > ) ) > > Is there a way to do this without having to use SQLFORM.factory and > inserting the data manually? > > Regards > Johann > -- > May grace and peace be yours in abundance through the full knowledge of God > and of Jesus our Lord! His divine power has given us everything we need for > life and godliness through the full knowledge of the one who called us by > his own glory and excellence. > 2 Pet. 1:2b,3a