I would like to add a second button to an exposed view form.
I am able to get the button to display, but not to have it call the button submit handler. Instead, it behaves just like the standard search button that views provides automatically.
How can I have my second button call a separate handler?
Below is what I've tried to do.
(FWIW, my specific goal is to let the user use the exposed view form to search for an existing node, then if he doesn't find it, to go ahead and post a new node. So, I want a button that will call an action to post a new node.)
function my_module_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'views_exposed_form':
if ($form['#id'] = 'views-exposed-form-my-module-page-1') {
// Add a button
$form['my_button']['#type'] = 'button';
$form['my_button']['#value'] = t('My Extra Button');
$form['my_button']['#submit'] = array('my_module_button_handler');
}
break;
}
}
function my_module_button_handler($form, &$form_state) {
// do something here
}