Author Topic: Field Type Select Dropdown producing duplicate values  (Read 3498 times)

mrfully

  • Beginner
  • *
  • Posts: 1
Field Type Select Dropdown producing duplicate values
« on: March 01, 2009, 02:57:17 am »
Hello,

I created a single select dropdown user field. The problem is every time I go to edit the field and add a new value, after saving it produces duplicate entries of the values that were listed initially.

Example: Initially I put some values in lets say Name 1 & Name 2
When I got back in to edit this field and add a new value lets say Name 3
After saving it now show Name 1 twice and Name 2 twice.
If I go in and edit the field again and add Name 3 it will show Name 1 three times, Name 2 three times and Name 3 twice.

Is there a way to prevent this so whenever I edit the field it will show the values and titles only once?

Thanks,
Charles

macallf

  • Hero Member
  • *****
  • Posts: 2411
    • Mark Callf Design
Re: Field Type Select Dropdown producing duplicate values
« Reply #1 on: March 01, 2009, 03:35:14 am »
This seems to be a bug!

I shall report it on the bug tracker.

The only way around it for now, is to create all values at creation time and don't modify the field.

Th eproblem is the query for user fields is an INSERT, this will just recreate all fields and not check for existing fields. Wrong way to do it.
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

PaulJaq

  • Beginner
  • *
  • Posts: 8
Re: Field Type Select Dropdown producing duplicate values
« Reply #2 on: March 03, 2009, 13:43:06 pm »
It also seems to default to the last item on the list, with 'select' at the top becoming a valid entry. Where is the bug tracker

aarondwyer

  • Beginner
  • *
  • Posts: 31
    • Business Web Hosting
Re: Field Type Select Dropdown producing duplicate values
« Reply #3 on: April 30, 2009, 13:27:17 pm »
I just added a message to this post about the very topic.

I added a screen shot and it's exactly the error.

http://forum.virtuemart.net/index.php?topic=45824.msg179640#msg179640

I concur with the select not being the default.

From now on I'll delete the form field and get all the options correct in the first pass.

Aaron

dugong

  • Beginner
  • *
  • Posts: 5
Re: Field Type Select Dropdown producing duplicate values
« Reply #4 on: May 21, 2010, 15:31:40 pm »
Has this problem been fixed yet? I have the same occurence

riefvan

  • Beginner
  • *
  • Posts: 3
    • CMI
Re: Field Type Select Dropdown producing duplicate values
« Reply #5 on: January 05, 2011, 00:24:42 am »
i made this 'temporary fix' to remove duplicate entries,

/************ delete duplicate entries *************/
$qnya="DELETE FROM #__{vm}_userfield_values USING #__{vm}_userfield_values, #__{vm}_userfield_values AS vtable WHERE vtable.fieldvalueid > #__{vm}_userfield_values.fieldvalueid AND #__{vm}_userfield_values.fieldtitle = vtable.fieldtitle";

$db->query($qnya);
/************ end of delete duplicate entries *************/

Open file: ps_userfield, find code like this:
      for($i=0; $i < $n; $i++) {
         if(trim($fieldNames[$i])!=null || trim($fieldNames[$i])!='') {
            $fields = array('fieldid' => (int)$d['fieldid'],
                              'fieldtitle' => htmlspecialchars($fieldNames[$i]),
                               'fieldvalue' => htmlspecialchars($fieldValues[$i]),
                              'ordering' => $j );
            $db->buildQuery( 'INSERT', '#__{vm}_userfield_values', $fields );
            $db->query();
            $j++;
         }
      }

and then put the fix below that code.

Tested on VM 1.1.3, but i guess it will works for other versions too.