Search code examples
phpdrupaldrupal-6

Drupal 7 : Advanced theme settings after submission


I have a problem with advanced settings in theme-settings.php. i can build custom form with this -->

mytheme_form_system_theme_settings_alter(&$form, &$form_state) {
 //custom form
}

function. But how i can integrate new function after settings submission? like this:

mytheme_system_theme_settings_submit_alter($form, &$form_state) {
  // if form submited -> execute function
}

Solution

  • You can add a custom submission handler to the form in the alter function itself:

    function mytheme_form_system_theme_settings_alter(&$form, &$form_state) {
      // Build up the rest of the form.
    
      // Add your submission handler to the form.
      $form['#submit'][] = 'mytheme_form_system_theme_settings_submit';
    }
    
    function mytheme_form_system_theme_settings_submit(&$form, &$form_state) {
      // Form has been submitted, execute your function.
    }