In gluon/sqlhtml.py there is the autocomplete widget. Copy it
somewhere with another name and replace
def callback(self):
if self.keyword in self.request.vars:
field = self.fields[0]
rows = self.db(field.like(self.request.vars[self.keyword]
+'%'))\
...
with
def callback(self):
if self.keyword in self.request.vars:
field = self.fields[0]
rows =
self.db(field.contains(self.request.vars[self.keyword]))\
...
On Feb 5, 12:32 pm, Unyo <[email protected]> wrote:
> Hi,
>
> The autocomplete widget currently searches for fields starting with
> whatever the user puts in. Is there any way to change this behavior to
> be like contains() rather then startswith()?
>
> A section of my db.py is below:
>
> db.define_table('building',
> Field('name'), format='%(name)s')
> db.define_table('student',
> Field('name'),
> Field('building', db.building),
> Field('room'),
> Field('forwarding'),
> Field('country'), format='%(name)s')
> db.define_table('mail',
> Field('student', db.student))
>
> db.mail.student.widget=SQLFORM.widgets.autocomplete(request,
> db.student.name, id_field=db.student.id)