You are here

function pardot_webform_form_alter in Pardot Integration 7.2

Implements hook_form_alter().

See also

pardot_webform_submit()

File

pardot_webform/pardot_webform.module, line 53
Pardot Webform integration module.

Code

function pardot_webform_form_alter(&$form, $form_state, $form_id) {
  if (strstr($form_id, 'pardot_admin_form')) {
    $form['pardot_validate_url'] = array(
      '#title' => t('Validate Pardot url'),
      '#type' => 'checkbox',
      '#description' => t('Validate Pardot form handler URL during webform creation.'),
      '#default_value' => variable_get('pardot_validate_url', 1),
      '#weight' => 0,
    );
  }
  elseif (strstr($form_id, 'webform_client_form')) {

    // Modify all webforms to use this output thingy.
    // Load the form specific settings.
    $nid = $form['details']['nid']['#value'];
    if (empty($nid)) {
      return;
    }
    $form_settings = pardot_webform_load($nid);

    // Check to see if the form exists.
    if (empty($form_settings) || !$form_settings->is_active) {
      return;
    }
    $form['#submit'][] = 'pardot_webform_submit';
  }
}