Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I needed to add a second submit handler to the batch update form.
I see in the batch form definition, you can define
'#submit' => 'custom_submit_handler',
However, that handler is only called if the domain_action is set to 'custom'
I needed to use both domain_conf as the handler and add a separate submit handler to do additional processing.
I ended up using the form_alter snippet below:
<?php
/**
* Implementation of hook_form_FORMID_alter
*/
function example_module_form_domain_batch_form_alter($form, &$form_state) {
// if custom handler set, let it handle the submit.
if( $form['handler']['#value'] == 'custom' ){
return;
}elseif( isset($form['submit_handler']) && function_exists($form['submit_handler']['#value']) ){
// add second submit handler, if present
$form['#submit'][] = $form['submit_handler']['#value'];
}
}
?>
That way domain_conf ( or the configured handler ) can handle saving the settings and then pass control onto another custom submit handler. If the handler is already set to custom, the domain module will add the submit_handler itself.
hth,
DT
Comments
Comment #1
agentrickardThere was a reason I had to code it this way, but I forget what it was...and it might be a limitation from D5.
I think the idea was that you would never need to do this (or that hook_form_alter() is the proper way.) This #submit is there if you want to bypass the normal save mechanisms.
Comment #2
agentrickardAPI change. Postponed.
Comment #3
agentrickard