Closed (works as designed)
Project:
Autocomplete Widgets for Text and Number Fields
Version:
6.x-1.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 May 2011 at 16:24 UTC
Updated:
12 May 2011 at 07:29 UTC
Comments
Comment #1
gthing commentedFurther testing shows only the last option with a given key value will be searchable. In the case of my example above, you will be able to search for Green but not Blue. If you add another line like 3|Yellow, then both Blue and Green will be unsearchable and you will only be able to search for Yellow.
Comment #2
markus_petrux commentedThis key should be unique. It is the same with nodes or users, for example, you cannot have more than one node with the ID equal to 3, or you cannot have more than one user with the ID 3.
Here the last value wins. See:
Each time $key is 3, the $value is stored in the same element of the array. So last value wins.
Comment #3
gthing commentedIn my case I am storing values for calories burned per hour for exercises. Two exercises might burn the same amount of calories. It seems like overkill to do exercises as nodes and use a node reference field. Is there a workaround?
Comment #4
markus_petrux commentedThe exercise is your entity here, and number of calories and hours are properties of that entity. The entity needs a key that gives a unique value for each exercise. There are several methods to do it. The most common one is using auto incremental keys, another method is to generate random keys with an algorithm that does not generate duplicates.
Because you need to manage two properties for each exercise, you need a container that is able to do that, for example a node + cck (Drupal 6), or there are other "fieldable" entities in Drupal 7.
PS: this issue is kind of beyond the scope of this module.