Steps to recreate:

  1. Install Drupal
  2. Install CCK
    • Content
    • Option Widgets
    • Text
  3. Enable Views
  4. Enable VBO
  5. Create field (Text -> Checkboxes/Radio Buttons)
    • Field name -> 'test'
    • Number of values -> Unlimited
    • Allowed values list -> Two unique values
      • value1|Value1
      • value2|Value2
  6. Create Action -> Modify Node Fields
    • Select the CCK text->checkboxes/Radio buttons created earlier
    • Select the "Add" Column
    • Select both CCK checkboxes
  7. Create a View (type->node)
    • Style -> Bulk Operations
    • Under "Selected Operations" select the action you created earlier
    • Create a page display for the view, give at URL, add at least one field
  8. Create a node
  9. Navigate to the VBO, select the node you created and execute the VBO at least twice

At this point we have exactly one node and both of the example checkboxes should be checked.

Expected result:
Database table {content_field_test} has 2 rows in it

Observed result:
Database table {content_field_test} has 4 rows in it - two for each time the VBO was executed.

VBO will continue to add values for the checkboxes each time the VBO is run. If you edit and save the node, the extra values are deleted from the table.

I suspect this stems from the fact that you need to select "Unlimited" for the number of values on a CCK checkbox/radio button field in order to display checkboxes (instead of radio buttons). But a single node should never have multiple values for a single checkbox.

My workaround is to run a query that deletes all "duplicate" rows (except for the one with the lowest delta) each time the VBO is executed.

CommentFileSizeAuthor
#1 VBO-multiple_values-1697862-2.patch536 bytesbalsama
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

balsama’s picture

Status: Active » Needs review
FileSize
536 bytes

I've attached a patch that performs an additional check to see if the field to be modified has a widget type of optionwidget_buttons. This eliminates the scenario where a single checkbox has multiple values in the DB. But it also means that you can never add values to a set of checkboxes, only overwrite the values. So for example, if you have a set of checkboxes A, B, and C, and, in one node, A & B are already checked and in another, only A is checked, it's impossible to add an action where you check C in addition to A and/or B.

balsama’s picture

Issue summary: View changes

Cleaned up formatting

joelpittet’s picture

Version: 6.x-1.13 » 6.x-1.x-dev
Status: Needs review » Closed (outdated)

Closing to clean up the queue