You are here

function key_config_form_submit in Key 7.2

Same name and namespace in other branches
  1. 7.3 includes/key.admin.inc \key_config_form_submit()

Form submission handler for key_config_form().

1 string reference to 'key_config_form_submit'
key_config_form in includes/key.admin.inc
Form constructor for the key configuration edit form.

File

includes/key.admin.inc, line 258
Administrative functionality for managing key configurations.

Code

function key_config_form_submit($form, &$form_state) {
  $provider = key_get_provider($form_state['values']['provider']);
  if ($submit_callback = ctools_plugin_get_function($provider, 'config form submit')) {
    call_user_func_array($submit_callback, array(
      $form,
      &$form_state,
    ));
  }

  // If the provider has changed, call the delete callback for the old
  // provider.
  if (isset($form['#original_key']['config'])) {
    $original_config = $form['#original_key']['config'];
    $original_provider = key_get_provider($original_config['provider']);
    if ($provider['name'] != $original_provider['name'] && ($delete_callback = ctools_plugin_get_function($original_provider, 'delete form submit'))) {
      call_user_func($delete_callback, $original_config);
    }
  }
  $fields = array(
    'name' => (string) $form_state['values']['name'],
    'label' => (string) $form_state['values']['label'],
    'description' => (string) $form_state['values']['description'],
    'provider' => (string) $form_state['values']['provider'],
    'provider_settings' => isset($form_state['values']['provider_settings']) ? serialize($form_state['values']['provider_settings']) : '',
    'created' => (string) $form_state['values']['created'],
  );
  key_save_config($fields);
  $form_state['redirect'] = KEY_MENU_PATH . '/list';
}