Auto-complete widget problem.

49 views
Skip to first unread message

annet

unread,
Apr 14, 2011, 3:17:25 AM4/14/11
to web2py-users
I have the following function:

def index():
form1=SQLFORM.factory(

Field('what',widget=SQLFORM.widgets.autocomplete(request,db.companykeyword.word))

Field('city',widget=SQLFORM.widgets.autocomplete(request,db.adres.plaats)))
form2=SQLFORM.factory(

Field('what',widget=SQLFORM.widgets.autocomplete(request,db.companykeyword.word)),

Field('zip',widget=SQLFORM.widgets.autocomplete(request,db.zip.region)))
form3=[]
if form1.accepts(request.vars,session,formname='form1'):
redirect(URL(r=request,c='locator',f='city',args=[]))
if form2.accepts(request.vars,session,formname='form2'):
redirect(URL(r=request,c='locator',f='zip',args=[]))
return dict(form1=form1,form2=form2,form3=form3)

and the following view:

<div class="threeColLayout">
<div class="secondCol" class="margin">
{{if form2:}}
<div class="colbox">
{{=form2}}
</div> <!-- colbox -->
{{pass}}
</div> <!-- secondCol -->
<div class="thirdCol" class="margin">
{{if form3:}}
<div class="colbox">
{{=form3}}
</div> <!-- colbox -->
{{pass}}
</div> <!-- thirdCol -->
<div class="firstCol" class="margin">
{{if form1:}}
<div class="colbox">
{{=form1}}
</div> <!-- colbox -->
{{pass}}
</div> <!-- firstCol -->
</div> <!-- threeColLayout -->


The problem is that form2's companykeyword auto-complete works and
form1's doesn't work. The city and zip auto-complete's both do work.

Does this mean I can't have two auto-complete fields in separate forms
based on the same database table? Is there a way to solve this
problem?


Kind regards,

Annet.

Tito Garrido

unread,
Apr 14, 2011, 7:44:29 AM4/14/11
to web...@googlegroups.com, annet
Hi Annet,

I had the same problem... I've changed the name of the second field... in your case "what"... try to put "what2" just to test...

Regards,

Tito
--

Linux User #387870
.........____
.... _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:_______

Massimo Di Pierro

unread,
Apr 14, 2011, 8:51:59 AM4/14/11
to web2py-users
... and? did it solve it?

annet

unread,
Apr 14, 2011, 11:32:58 AM4/14/11
to web2py-users
@Tito,

Thanks for your reply. I tried changing the name of the what field in
the second form:


def index():
form1=SQLFORM.factory(

Field('what',widget=SQLFORM.widgets.autocomplete(request,db.companykeyword.word))

Field('city',widget=SQLFORM.widgets.autocomplete(request,db.adres.plaats)))
form2=SQLFORM.factory(

Field('what2',widget=SQLFORM.widgets.autocomplete(request,db.companykeyword.word)),

Field('zip',widget=SQLFORM.widgets.autocomplete(request,db.zip.region)))
form3=[]
if form1.accepts(request.vars,session,formname='form1'):
redirect(URL(r=request,c='locator',f='city',args=[]))
if form2.accepts(request.vars,session,formname='form2'):
redirect(URL(r=request,c='locator',f='zip',args=[]))
return dict(form1=form1,form2=form2,form3=form3)


When I type a word in the first form's what field, the drop box with
auto-complete results appears below the second form's what2 field.


@Massimo,

> ... and? did it solve it?

No, the problem still exists :-(
I guess it has something to do with the id in both cases being:
#_autocomplete_word_div


Kind regards,

Annet
Reply all
Reply to author
Forward
0 new messages