You can workaround that problem like this : db.define_table('person', Field('name', unique=True, requires=IS_NOT_IN_DB(db,' person.name')), Field('country', 'string'), Field('age', 'integer'))
db.define_table('thing', Field('name', 'string'), Field('persona', 'reference person', requires=IS_IN_DB(db, ' person.id', '%(name)s')), Field('personb', 'reference person', requires=IS_IN_DB(db, ' person.id', '%(name)s')) ) db.thing.persona.widget = SQLFORM.widgets.autocomplete(request, db.person.name, id_field=db.person.id, *keyword='_autocomplete_thing_persona'*) db.thing.personb.widget = SQLFORM.widgets.autocomplete(request, db.person.name, id_field=db.person.id, *keyword='_autocomplete_thing_personb'*) Which was maybe the intent of having keyword attribute... I don't know... Richard On Tue, Feb 2, 2016 at 3:54 PM, Richard Vézina <ml.richard.vez...@gmail.com> wrote: > Error come from : > https://github.com/web2py/web2py/blob/63bb4a7e8a39f466f6269e2f98c7b741d001def9/gluon/sqlhtml.py#L648 > > And here : > https://github.com/web2py/web2py/blob/63bb4a7e8a39f466f6269e2f98c7b741d001def9/gluon/sqlhtml.py#L657 > > The widget can't use the same field name... > > There is already a ticket on github about that : > https://github.com/web2py/web2py/issues/940 > > > Can be reproduce with this code : > > # model > db.define_table('person', > Field('name', unique=True, requires=IS_NOT_IN_DB(db,' > person.name')), > Field('country', 'string'), > Field('age', 'integer')) > > db.define_table('thing', > Field('name', 'string'), > Field('persona', 'reference person', requires=IS_IN_DB(db, > 'person.id', '%(name)s')), > Field('personb', 'reference person', requires=IS_IN_DB(db, > 'person.id', '%(name)s')) > ) > > db.thing.persona.widget = SQLFORM.widgets.autocomplete(request, > db.person.name, id_field=db.person.id) > db.thing.personb.widget = SQLFORM.widgets.autocomplete(request, > db.person.name, id_field=db.person.id) > > > # controller > def create(): > form = SQLFORM(db[request.args(0)]) > form.process(detect_record_change=True) > if form.record_changed: > pass > # do something > elif form.accepted: > pass > # do something else > else: > pass > # do nothing > return dict(form=form) > > You need to pass : person or thing as argument 0 > > Richard > > On Tue, Feb 2, 2016 at 3:32 PM, Richard Vézina < > ml.richard.vez...@gmail.com> wrote: > >> If you can pack a dummy app to help us reproduce the problem it could >> help... >> >> Richard >> >> On Tue, Feb 2, 2016 at 3:31 PM, Richard Vézina < >> ml.richard.vez...@gmail.com> wrote: >> >>> Pierre, >>> >>> You crop the interresting part... after the etc.... >>> >>> The error is surely coming from the jQuery which for some reason don't >>> get generated properly by the widget... >>> >>> Richard >>> >>> On Tue, Feb 2, 2016 at 3:29 PM, Richard Vézina < >>> ml.richard.vez...@gmail.com> wrote: >>> >>>> Did you try to set the type to these fields? >>>> >>>> db.define_table('thing', >>>> Field('name'), >>>> Field('persona', 'reference person'), >>>> Field('personb', 'reference person')) >>>> >>>> On Tue, Feb 2, 2016 at 3:10 PM, Pierre <theognis0...@gmail.com> wrote: >>>> >>>>> In fact Yes >>>>> >>>>> >>>>> the second input replaces the first : >>>>> >>>>> personb replaces persona and personb ends up empty >>>>> >>>>> -- >>>>> 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. >>>>> >>>> >>>> >>> >> > -- 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.