Closed (fixed)
Project:
Views Bulk Operations (VBO)
Version:
6.x-1.9
Component:
Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Feb 2010 at 19:44 UTC
Updated:
30 Mar 2010 at 23:33 UTC
I'm working with agentrickard on integrating Domain Access with VBO (Views Bulk Operations). We're almost done, but we need to get our form callback to fire *after* the confirmation page. Does anyone know how to do this?
Basically, we use hook_form_alter() to add more options to the form, and process these results by looking at the form values when our callback is called via
$form['#submit'][] = 'domain_content_update_nodes';
The problem is
a) The form callback is called on the confirmation page, not after it.
b) hook_node_operations() doesn't pass the form values. This also seems related to #505466: Extending hook_node_operations for supporting forms..
Thanks!
- Yonas
Comments
Comment #1
infojunkiea) Take a look at
views_bulk_operations_form_submit()in views_bulk_operations.module. It is called at each submission of the multi-step form, and decides what to do depending on the step it's in.b) If you're altering the VBO form itself, then be aware that the form values for each step are stored in
$form_state['storage']. Look there for your values.Comment #2
fizk commentedThanks infojunkie, that worked :)
http://drupal.org/node/710712#comment-2593678
Comment #3
fizk commentedWhen using the confirmation step, how do we get VBO to call us after the user has confirmed that they want to execute the operation?
Comment #4
infojunkieYou can add a submit handler where you check for the step in$form_state['storage'].Sorry, you're already using a submit handler. So what is the problem? Are you being called *after* execution while you want to be called before? If that's the case, insert your submit handler at the head of the array instead of its tail.
Comment #5
fizk commentedI think it's working now. I return array($form, $form,state) if step == 2, and VBO passes this array as arguments to our operations callback.
The operations callback passes $form, and $form_state to our submit handler code. From there we're acting as though it's a regular Form API submit callback.
Comment #6
fizk commentedIf this seems inefficient, please let me know of a better way. This will have to work for any amount of nodes people are use to throwing at VBO.
I tested using VBO in Batch mode, and it worked for two nodes. I wish I had 10000 nodes to test against :)
Comment #7
infojunkieI'm afraid I don't follow you. Can you point me to code I can read?
I regularly test with 10K nodes. Use devel to generate them!
Comment #8
fizk commentedThe code is in comment #56: http://drupal.org/node/710712
The operations hook is
function domain_content_node_operations() { ...Comment #9
infojunkieI read the code, but I guess I don't understand the use case. Why can't this be a normal action that operates node by node? Does it need to be a node operation? And even so, isn't it an operation that the admin or user selects in a VBO? Feel free to close this if you're losing your patience with me :-)
Comment #10
fizk commented> Why can't this be a normal action that operates node by node?
Good question :) I'll if we can refactor the code.
> Does it need to be a node operation?
Since each node can be associated to domain(s), this should be a node operation.
> And even so, isn't it an operation that the admin or user selects in a VBO?
Yup. The user selects the node he wants to configure, then on the next page, selects which domains to assign to those nodes, then confirmation page, then done.
> Feel free to close this if you're losing your patience with me :-)
Thanks for having patiences with me! :) We have working code, but I'd like to leave his issue open so that I have easy access to you :)
Comment #11
infojunkieBased on what you say, I think you're approaching the problem the wrong way. Here's what I suggest:
* Create an action, not a node_operation
* Declare this action to be configurable, since you want to let the user select the domain(s)
* Select your new action on your view's 'Bulk operations' settings page
* Done!
Read the VBO development guide - especially the link on how to write actions. Also take a look at real-life actions in the VBO module folder.
Comment #12
fizk commented* Create an action, not a node_operation
> What's the benefit to creating an action instead of node_operation?
* Declare this action to be configurable, since you want to let the user select the domain(s)
> we're already doing this
* Select your new action on your view's 'Bulk operations' settings page
> we're already doing this
Comment #13
infojunkie> What's the benefit to creating an action instead of node_operation?
Nothing much, except that the fact that VBO supports 'configurable' for node_operations is a hack, whereas actions are designed to work with 'configurable'.
Also, the patch that you refer to indicates that you process the nodes when VBO calls your action's submit function. The actions guide explains that the action submit form should not execute the action, but just prepare the parameters that will be passed to the action function. Again, looking at the existing actions in VBO should clarify this.
Comment #14
drupalok commentedsubscribing
Comment #15
tester1x commentedComment #16
tester1x commentedComment #17
fizk commentedEveryone that needs VBO support, head over to http://drupal.org/project/domain_actions.
infojunkie, thanks for all your help!