Closed (fixed)
Project:
Autocomplete Widgets for Text and Number Fields
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Oct 2012 at 14:29 UTC
Updated:
20 Jun 2018 at 15:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bleen commentedDave Kopecek ... have you confirmed this issue?
Comment #2
dave kopecekYes. It looks like the problem is in autocomplete_widgets.common.inc, in
The function is sorting a keyed array using sort($options) rather than asort($options).
Commenting out the code in _autocomplete_widgets_sort_options() "fixes" the issue...of course it doesn't honor the sort preference.
Not sure yet what else calls the sort function so I'm not quite prepared to submit a straight sort()->asort() substitution patch.
Looks like straight sort()->asort() substitutions does the trick.
Comment #3
chaby commentedsame problem too and Dave Kopecek solution seems to do the trick (thank you !).
Indeed, sort and rsort don't maintain indice keys correlations, whereas asort/arsort do it.
As a result, each time autocomplete widgets allowval process is executed, it will populate form state values with numeric value sorted rather than allowed values key...
Here a quick patch from Dave Kopecek tricks but awaiting for a fix applied to the dev branch soon.
thanks
Comment #4
ItangSanjana commentedPatch on #3 work to me. Thanks
Comment #5
regilero commentedpatch #3 seems to do the trick
Comment #6
bleen commentedlets see if testbot likes the patch in #3
Comment #7
tacoparty commentedI applied the patch but am still seeing 0 for the fields instead of the data in the field setup.
Here is the section that was changed in autocomplete_widgets.common.inc:
function _autocomplete_widgets_sort_options(&$options, $instance) {
if (isset($instance['widget']['settings']['order'])) {
switch ($instance['widget']['settings']['order']) {
case 'ASC':
asort($options);
break;
case 'DESC':
arsort($options);
break;
}
}
Did I screw up somewhere?
I also noticed this patch doesn't appear to be in the latest dev release but wasn't sure how that works, exactly.
Thanks for any help anybody can give me!
Comment #8
tacoparty commentedNever mind. I believe this works now for any new data that is entered. I was refreshing the existing view and it was still returning 0. However, when I entered in new information to the form field, it seems to work.
Comment #9
bleen commentedThis works with the patch from #3? Or it works without needing a patch?
Comment #10
tacoparty commentedIt works with the patch when adding new content. Previous content was still not displaying but I'm not concerned about that since it was a new section anyway.
Comment #11
jromine commentedPatch in #3 tested and works (on Drupal 7.20).
Comment #12
bleen commentedCommitted the patch from #3 ...thanks!
Comment #14
mustanggb commented