5

If I create a Rules Action to set the value of a CCK field, and point to that action from VBO, is there a way to add user inputs to the VBO form on the views page to pass parameters to the Rules Action?

I would prefer a way to do this through GUI if possible.

8
+100

Explaining how to create Rule that accept arguments (user can enter any value) and adding VBO field in Views: The Power of Rules with Views Bulk Operations (and Commerce)

From Joren comment:

 function modulename_form_views_form_test_view_page_alter(&$form, $form_state, $form_id) { 
    $form['#submit'][] = 'modulename_vbo_submit'; 
    $form['select']['arg'] = array( '#type' => 'textfield', '#title' => t('Whatever') ); 
 } 
 function modulename_vbo_submit(&$form, $form_state) { 
   $nids = $form_state['selection']; 
   foreach ($nids as $nid) { 
     $node = node_load($nid); 
     rules_invoke_component('rules_test', $node, $form_state['values']['arg']); 
     drupal_goto('test-view');
   } 
 }
  • This is almost exactly what I needed. The only missing piece is getting the form field to be on the same page as the view. I don't like the intermediate step for entering that value. – Joren Oct 10 '11 at 19:07
  • well, in this case you can only write custom module. – Nikit Oct 10 '11 at 20:24
  • 1
    Can the custom module just move the form to the views page, but the rest of the functionality come from the Action? If so, do you know how? – Joren Oct 10 '11 at 20:45
  • I assume you can catch VBO form in Views via hook_form_alter and adding input box there, then adding own submit with calling rules action. – Nikit Oct 10 '11 at 21:23
  • I can't figure out how to call a rules action. :\ Being able to add arguments is great, but having it be a separate step makes it fairly poor for something users are supposed to use. – Joren Oct 11 '11 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.