Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using the module to autocomplete from existing field data, using a 'contains' search. At the moment, I have four unique field entries:
Artist D 100% (ASCAP)
Artist D 50% (ASCAP)
Artist J 100% (ASCAP)
Artist J 50% (ASCAP)
If I type "5" I get both Artist D 50% (ASCAP) and Artist J 50% (ASCAP). However, "J" gives me Artist J 100% (ASCAP), "D" gives me Artist D 100% (ASCAP) -- neither one with the 50% option.
Comment | File | Size | Author |
---|---|---|---|
#7 | 1430418.patch | 454 bytes | bleen |
Comments
Comment #1
bleen CreditAttribution: bleen commentedcan you export your content type and post the result. So far I am unable to reproduce
Comment #2
mrtoner CreditAttribution: mrtoner commentedI'm not sure how to export a content type?
Comment #3
bleen CreditAttribution: bleen commentedI have spent some time this morning on this with another developer at Drupalcon and we simply cannot reproduce. The only possible cause we came up with is that perhaps you chose "case-sensitive" when setting up the widget and the actual data you have is not the same case.
So, unless you can give me reproducible steps I'm going to close this issue.
Comment #4
mrtoner CreditAttribution: mrtoner commentedI dug into this a bit tonight, figured out the query you're building and found that you can easily reproduce this:
1. Create a field with an autocomplete widget, using existing field values, and assign it to a content type.
2. Create 10 nodes of that content type. For each of the fields with the autocomplete widget, give it a value of "John Smith".
3. Create an 11th node, with a field value of "John Carter".
4. Create node #12 -- type "j" in the field. "John Carter" will not show as a possible option.
The problem is here:
$options = _autocomplete_widgets_get_options($field, $string, $match, NULL, 10);
You're attempting to limit the number of options to 10, but what is actually happening is that you've limited the number of records returned by the query to 10 -- the first 10. Instead, you need to return all possible values from the db, reduce those to only unique values, and then reduce those to 10.
Comment #5
bleen CreditAttribution: bleen commentedThat's a different scenario than the one in your original post ... I was only testing with 4 elements.
I'll take a closer look at this.
Comment #6
mrtoner CreditAttribution: mrtoner commentedSorry, I wasn't clear (as I realized when I last posted): that was four unique values, with 200+ total entries.
Comment #7
bleen CreditAttribution: bleen commentedI didnt have a ton of time to test this, but I think this should work.... can you please kick the tires
Comment #8
mrtoner CreditAttribution: mrtoner commentedSeems to work fine, if
$selct->distinct();
is
$select->distinct();
Comment #9
bleen CreditAttribution: bleen commentedok .. I committed this to dev (with "select" spelled correctly)
Wooot!
Comment #10
mrtoner CreditAttribution: mrtoner commentedAny chance of getting the returned results sorted alphabetically?
Comment #11
bleen CreditAttribution: bleen commentedmrtoner ... open a new issue (feature request)
Comment #13
mrogers CreditAttribution: mrogers commentedJust want to confirm that I experienced this issue today (both with stable and dev) and the patch in #7 fixed it.
Comment #14
bleen CreditAttribution: bleen commentedI dont understand ... this was added to DEV here: http://drupalcode.org/project/autocomplete_widgets.git/commit/9664748. Did you have to re-patch?
Comment #15
mrogers CreditAttribution: mrogers commentedYep, had to repatch. It's not in the 7.x dev version linked on the project page, as far as I can tell.