You are here

function hubspot_webform_form_alter in HubSpot 7.3

Same name and namespace in other branches
  1. 7.2 hubspot_webform/hubspot_webform.module \hubspot_webform_form_alter()

Implements hook_form_alter().

File

hubspot_webform/hubspot_webform.module, line 220
Sends Webform results to HubSpot's Forms API.

Code

function hubspot_webform_form_alter(&$form, $form_state, $form_id) {
  if (strstr($form_id, 'webform_client_form')) {
    $nid = $form['details']['nid']['#value'];
    if (empty($nid)) {
      return;
    }

    // Check to see if this is configured for Hubspot
    if (!db_query('SELECT count(*) FROM {hubspot} WHERE nid = :nid', array(
      ':nid' => $nid,
    ))) {
      return;
    }
    $form['#submit'][] = 'hubspot_webform_submit';
  }
  elseif (strstr($form_id, 'hubspot_admin_settings')) {
    module_load_include('inc', 'hubspot_webform', 'hubspot_webform.admin');
    _hubspot_webform_admin_settings($form);
  }
}