Closed (fixed)
Project:
Views Bulk Operations (VBO)
Version:
6.x-1.5
Component:
Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Mar 2009 at 16:16 UTC
Updated:
24 Jun 2011 at 06:59 UTC
I have tried to override the #submit, #validate, and #action properties via *_form_alter(), which look right in my debug traces, but my custom handlers don't seem to get fired at all.
For now, I'm just trying to post the form to a new URL and snag the nid's of selected nodes, and not run an action - hence me trying to alter #action as well. In the markup, I see my new action URL, but when the submit button is clicked I get redirected to the same view, but with empty node results.
A little background here, I am using D6 + VBO 1.5 + Views 2 w/exposed search filter field. Below is an example snippet of my code.
/**
* Implementation of hook_form_alter()
*/
function mymodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'views_bulk_operations_form_1') {
$form['#submit'] = array('mymodule_custom_vbo_form_submit');
$form['#validate'] = array('mymodule_custom_vbo_form_validate');
$form['#action'] = '/new/page?nids=1111,2222';
}
}
function mymodule_custom_vbo_form_submit($form, &$form_state) {
drupal_set_message('Party from the submit function!');
drupal_goto('new/page', 'nids=1111,2222');
}
function mymodule_custom_vbo_form_validate($variables) {
echo('Party from the validation function!');
}
Comments
Comment #1
infojunkieThe following action which redirects to another page works for me. I placed it inside the VBO folder (named goto.action.inc) to avoid writing a new module:
That said, using actions will not work in your target scenario of comparing two nodes on one screen. That is because the action is called *once for every selected node*, instead of being called once with all the selected nodes in one array that you can then use to redirect to your new page, giving it the nids as arguments.
I suggest implementing hook_node_operations() that returns a new operation that you supply. Node operations, as opposed to actions, are called once with all selected nodes in an array, which is what you need. Your operation would simply redirect to your node comparison page with the nids on the URL.
Comment #2
infojunkieMarking as fixed if you don't mind.
Comment #4
sahasra commentedfunction quotecovers_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == '_helper_callback_ahah_form') {
$form['#submit'] = '_helper_callback_ahah_form_submit';
$form['#validate'][] = '_helper_callback_ahah_form_validate';
$form['#action'] = url('test.php');
$form['#method'] = 'post';
}
//
// return $form;
}
I used this code validation not working when i am click submit button it goes directly test.php page it is not checking validations plz give me solution
Comment #5
infojunkie@sahasra: not sure your question is related to VBO. Check the community page to find out where to ask your question.
Comment #6
sahasra commentedVBO means this form api question i used hook_form_alter