You are here

function hosting_alias_form_js in Hosting 6.2

AHAH callback for additional alias form fields.

Copied from poll_choice_js()

1 string reference to 'hosting_alias_form_js'
hosting_alias_menu in alias/hosting_alias.module
Implementation of hook_menu().

File

alias/hosting_alias.module, line 209
Allow sites to have domain aliases that they can be accessed with.

Code

function hosting_alias_form_js() {
  include_once 'modules/node/node.pages.inc';
  $form_state = array(
    'storage' => NULL,
    'submitted' => FALSE,
  );
  $form_build_id = $_POST['form_build_id'];

  // Get the form from the cache.
  $form = form_get_cache($form_build_id, $form_state);
  $args = $form['#parameters'];
  $form_id = array_shift($args);

  // We will run some of the submit handlers so we need to disable redirecting.
  $form['#redirect'] = FALSE;

  // We need to process the form, prepare for that by setting a few internals
  // variables.
  $form['#post'] = $_POST;
  $form['#programmed'] = FALSE;
  $form_state['post'] = $_POST;

  // Build, validate and if possible, submit the form.
  drupal_process_form($form_id, $form, $form_state);

  // This call recreates the form relying solely on the form_state that the
  // drupal_process_form set up.
  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

  // Render the new output.
  $alias_form = $form['aliases_wrapper'];
  unset($alias_form['#prefix'], $alias_form['#suffix']);

  // Prevent duplicate wrappers.
  $output = theme('status_messages') . drupal_render($alias_form);
  drupal_json(array(
    'status' => TRUE,
    'data' => $output,
  ));
}