You are here

function autodialog_form_alter in Auto-Dialog 7

Implements hook_form_alter().

File

./autodialog.module, line 89

Code

function autodialog_form_alter(&$form, &$form_state, $form_id) {
  static $asaf_module_enabled;
  if ($asaf_module_enabled === NULL) {
    $asaf_module_enabled = module_exists('asaf');
  }
  if (!$asaf_module_enabled) {
    return;
  }
  if (_autodialog_check_request() && !empty($_POST['autodialog_options']['ajax']) || !empty($form_state['complete form']['#autodialog'])) {
    $form['#autodialog'] = TRUE;
    $form['#autodialog_options'] = isset($_POST['autodialog_options']) ? $_POST['autodialog_options'] : $form_state['complete form']['#autodialog_options'];
    asaf_prepare_form($form, $form_state);

    // Support Webforms
    if (strpos($form_id, 'webform_client_form_') === 0 && isset($form['actions']['submit']['#pre_render']) && ($key = array_search('webform_pre_render_remove_id', $form['actions']['submit']['#pre_render'])) !== FALSE) {
      unset($form['actions']['submit']['#pre_render'][$key]);
    }
  }
}