Stop a custom submit button from firing the form validation on a CCK form
- by kidrobot
I've added a submit button inside a fieldgroup on a CCK form using hook_form_alter as follows:
function mymodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'object_node_form') {
$form['group_wikipedia']['search'] = array(
'#type' => 'submit',
'#value' => t('Search Wikipedia'),
'#name' => 'searchwiki',
'#submit' => array('mymodule_searchwiki_submit'),
);
}
}
When I press the button, the validation handlers for the full form eg. checks for required fields, run as though I have pressed the 'Submit' button at the end of the form.
I thought that changing the #name property from 'op' to 'searchwiki' would prevent this kind of mix-up, but not so.
Does anyone know a workaround for this?