You are here

function variable_form_alter in Variable 7.2

Same name and namespace in other branches
  1. 7 variable.module \variable_form_alter()

Implements hook_form_alter().

Triggers hook_variable_realm_settings_form_alter() giving other modules a chance to act on settings forms after other contrib modules have added their variables.

File

./variable.module, line 686
Variable API module

Code

function variable_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['#submit']) && is_array($form['#submit']) && in_array('system_settings_form_submit', $form['#submit'])) {

    // Replace submit callback and use our own function.
    $form['#submit'] = str_replace('system_settings_form_submit', 'variable_settings_form_submit', $form['#submit']);
    $alter = TRUE;
  }
  elseif (isset($form['#variable_edit_form'])) {

    // This is a variable form, just invoke the hook but don't change submit callback.
    $alter = TRUE;
  }
  if (!empty($alter)) {
    foreach (module_implements('variable_settings_form_alter') as $module) {
      $function = $module . '_variable_settings_form_alter';
      $function($form, $form_state, $form_id);
    }
  }
}