0

I would like to initiate theme registry rebuild(drupal_theme_rebuild) on a particular form submit. This is admin form for my custom settings:

function HOOK_menu(){
 $items['admin/some-url'] = array(
        'title' => 'Custom Settigns',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('my_admin_interface'),
        'access arguments' => array('administer users'),
        'type' => MENU_NORMAL_ITEM,
    );
 return $items;
}

function my_admin_interface($form, $form_state)
{
    $form['some_settings'] = array(...);
    return system_settings_form($form);
}

The form works well and the settings are being saved, however. The changes involve theme functions, so I need to rebuild the registry whenever the form is submited. What is the best approach? Can I attach to form element function drupal_theme_rebuild or there is hook I can use to call drupal_theme_rebuild(). What is the best way rebuild theme registry after a form is processed and new settings saved. Thank you for your help

  • so far the best DRupal function to flush cache drupal_flush_all_caches – latvian Jan 3 '15 at 6:40
2

In order to fire a submit callback you have to add it to #submit array within your form. Here is an example.

/**
 * Form builder.
 */
function my_admin_interface($form, $form_state) {
  $form['#submit'][] = 'my_admin_interface_submit';
  return system_settings_form($form);
}

/**
 * Submit handler.
 */
function my_admin_interface_submit($form, $form_state) {
  drupal_set_message(t('Hey there!'));
}

Here is a link to the manual.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.