I want to create an vbo action to update cck multiple field. in this case i wanto to update a field value from '0' to '1'.

This code below ilustrated what i have been made. This code only can update multiple field with index 0. i can not get index from $form_state.

function wespi_po_key_to_value($entity){
switch($entity){
    case 0:
        $value = 'No';
    break;
    case 1:
        $value = 'Yes';
    break;
}
return $value;}


function wespi_po_receive_this_items($entity,$context){
global $user;
$prev_field_receive = $entity->field_receive[LANGUAGE_NONE][0]['value'];
//$nodes = node_load($entity->nid);

if ($prev_field_receive == 0){
    $entity->field_receive[LANGUAGE_NONE][0]['value'] = 1;
}
elseif($prev_field_receive == 1){
    $entity->field_receive[LANGUAGE_NONE][0]['value'] = 0;
}
node_save($entity);
$current_field_receive = $entity->field_receive[LANGUAGE_NONE][0]['value'];
$output = 'previous value : ' . wespi_po_key_to_value($prev_field_receive) . '<br />';
$output .= 'current value : ' . wespi_po_key_to_value($current_field_receive) . '<br />';
drupal_set_message($output);
return;}

Please help how to update several field in $entity->field_receive not only for index 0 but all index base on item selected in vbo form. i have attach in image to describe my problem. this image describe the result my code vbo action to update multiple field/

I really need help, after a week to find a documentation in forums.

Comments

bojanz’s picture

Status: Active » Closed (won't fix)

I have no idea what is being asked, and the code sample provided is very poor and doesn't give me any ideas.

You can read the actions that VBO includes (the "actions" folder) to see how aggregate actions work (getting all entities at once, but prone to timeouts), or simulating the same thing without aggregation (in archive.action.inc). You can also read the module documentation.