I changed the validator in trunk IS_IN_DB. Now it should be automatically grouping similar items. Optionally you can specify IS_IN_DB(...,groupby=...) Give it a try.
On Jun 8, 11:07 pm, "mr.freeze" <nat...@freezable.com> wrote: > Actually, that will not work since it modifies the collection in a > loop. Try this: > > def unique_items_widget(f,v): > inp = SQLFORM.widgets.options.widget(f,v) > options = inp.elements('option') > vals = [] > inp.components = [] > for opt in options: > val = opt['_value'] > if not val in vals: > vals.append(val) > inp.append(opt) > return inp > > On Jun 8, 10:18 pm, "mr.freeze" <nat...@freezable.com> wrote: > > > mdpierro is just saying that a simple patch needs to be made to > > IS_IN_DB. Until then, you can create a widget to remove duplicates: > > > def unique_items_widget(f,v): > > inp = SQLFORM.widgets.options.widget(f,v) > > vals = [] > > for k, opt in enumerate(inp): > > if not opt['_value'] in vals: > > vals.append(opt['_value']) > > else: > > del inp[k] > > return inp > > > vul.authors.name.widget = unique_items_widget > > > On Jun 8, 8:49 pm, kike <eacarm...@estudiantes.uci.cu> wrote: > > > > In what part of the sentence > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) I need > > > aggregate a groupby option to work, because in that sentence that > > > parameter is incorrect and if I aggregate a groupby parameter in > > > f=SQLFORM.factory(vul.authors.name) nothing append. > > > How I can fixed that > > > thank for your help > > > > On Jun 8, 1:39 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > haha. I think we need to add a groupby option to IS_IN_DB. > > > > > On Jun 7, 5:16 pm, kike <eacarm...@estudiantes.uci.cu> wrote: > > > > > > Hi I need a form to search, and in that form a field with some > > > > > database values, I wrote the following > > > > > > vul.authors.name.requires=IS_IN_DB(vul,vul.authors.name) > > > > > f=SQLFORM.factory(vul.authors.name) > > > > > > that work perfect but my problems is in my database exist several > > > > > authors with the same name, and that code list all of them, how I show > > > > > only one of all of the same name. > > > > > > thank for your help