Adding an extra own submit function to another modules form
This is how you can add your own submit function to another modules form. To make this work I had to increase the weight on my module to override the other module. Then I had to rearrange the submit function order to make it first call my function and then call the other submit function.
In this function I also had to add weight to the existing form because it was missing. If you try to add a form element without weight it will end up first or after the submit buttons, and that's not so nice.
<?php
function support_filter_form_alter(&$form, $form_state, $form_id) {
if ($form_id == "support_admin_client") {
$w = 0;
foreach ($form as $key => $value) {
$w++;
if (stripos($key, "#") === FALSE) {
$form[$key]['#weight'] = $w;
}
}
$form['logs_record'] = array(
'#type' => 'checkbox',
'#weight' => 7,
'#default_value' => variable_get("support_filter_logs_record_".$form['clid']['#value'], 1),
'#title' => t('Special log filter.'),
'#description' => t('Marked, this clients incoming mail will be filtered according to specific rules and some mails will be deleted without even notifying site admin. Deleted mail will instead be logged.'),
);
$temp_form = $form['#submit'];
unset($form['#submit']);
$form['#submit'][] = "domainuser_users_submit";
foreach ($temp_form as $id => $submit) {
$form['#submit'][] = $submit;
}
}
}
function support_filter_client_submit($form, $form_values){
variable_set("support_filter_logs_record_".$form_values['values']['clid'], $form_values['values']['logs_record']);
}
?>
Knowledge keywords: