On 9 May 2011 15:16, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote:
> 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)) > > > While this works as far as the autocomplete widget is concerned another problem has arised: I get an error: 'Value already in database or empty' when the widget is used with crud when used in the following way: The user has to enter a doc_nr where the history of generating the document references are so complex that it not worth while to try and write code to do that automatically. I want to use the autocomplete widget to show the user what is already in the database as far as similar references are concerned to enable him/her to type in a unique one. I know this is not the usual usage of the autocomplete widget, and I can continue to use it with SQLFORM.factory but would like to know whether I can bypass this problem using CRUD. 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