I have a multistep form created with msnf for an content type. I set multiple submit buttons that each one has its own submit callback, and also i want every single button with its validation callback :
function MYMODULE_form_alter(&$form, &$form_state, $form_id){
switch ($form_id){
case "my_form_id" :
$form['actions']['submit_2'] = array(
'#type' => 'submit',
'#name' => 'button_name',
'#value' => t('Name'),
'#weight' => 6,
'#submit' => array('node_form_submit'),
'#validate' => 'MYMODULE_validate_2'
);
// Add submit callback (works fine!)
array_unshift($form['actions']['submit_2']['#submit'], 'MYMODULE_form_submit_2');
// rest of code ...
}
}
inside the validation callback i put this test code :
function MYMODULE_validate_2($form, &$form_state){
dpr('test');
exit;
}
Here i have two problems :
1) this validation callback didn't triggered i don't know why ? (the system must show me a dump 'test' and then exit but nothing happen!)
2) I want to disable all the required fields only when i click on this submit_2 button.
I found sth in this post, but like i said the validation callback is not handled so i can't test the code inside that post.
Thanks in advance.
EDIT I was blind :p I must put the callback function inside an array() like this
'#validate' => array('MYMODULE_validate_2')
sometime i made stupid error :)
Now my problem is only the second one :
- I want to disable all the required fields only when i click on this submit_2 button.