You are here

function modal_forms_personal_contact in Modal forms (with ctools) 7

A modal personal contact form.

1 string reference to 'modal_forms_personal_contact'
modal_forms_menu in ./modal_forms.module
Implements hook_menu().

File

./modal_forms.pages.inc, line 154
Page callbacks for the modal_forms module.

Code

function modal_forms_personal_contact($recipient, $js = NULL) {
  module_load_include('inc', 'contact', 'contact.pages');

  // Fall back if $js is not set.
  if (!$js) {
    return drupal_get_form('contact_personal_form', $recipient);
  }
  ctools_include('modal');
  ctools_include('ajax');
  $form_state = array(
    // 'title' => t('Contact'),.
    'build_info' => array(
      'args' => array(
        $recipient,
      ),
    ),
    'ajax' => TRUE,
  );
  $output = ctools_modal_form_wrapper('contact_personal_form', $form_state);
  if (!empty($form_state['executed'])) {

    // We'll just overwrite the form output if it was successful.
    $output = array();
    ctools_add_js('ajax-responder');
    if (isset($_GET['destination'])) {
      $output[] = ctools_ajax_command_redirect($_GET['destination']);
    }
    else {
      $output[] = ctools_ajax_command_reload();
    }
  }
  print ajax_render($output);
}