You are here

function hubspot_webform_settings_submit in HubSpot 7.2

Same name and namespace in other branches
  1. 7.3 hubspot_webform/hubspot_webform.admin.inc \hubspot_webform_settings_submit()

Submit handler for hubspot_webform_settings().

1 string reference to 'hubspot_webform_settings_submit'
_hubspot_webform_admin_settings in hubspot_webform/hubspot_webform.admin.inc
Hubspot webform admin settings.

File

hubspot_webform/hubspot_webform.admin.inc, line 225
Provides admin settings page to adjust form submission settings.

Code

function hubspot_webform_settings_submit($form, &$form_state) {
  $txn = db_transaction();

  // Check if webform values even exist before continuing.
  if (isset($form_state['values']['webforms'])) {
    foreach ($form_state['values']['webforms'] as $key => $settings) {
      db_delete('hubspot')
        ->condition('nid', str_replace('nid-', '', $key))
        ->execute();
      if ($settings['hubspot_form'] != '--donotmap--') {
        foreach ($settings[$settings['hubspot_form']] as $webform_field => $hubspot_field) {
          $fields = array(
            'nid' => str_replace('nid-', '', $key),
            'hubspot_guid' => $settings['hubspot_form'],
            'webform_field' => $webform_field,
            'hubspot_field' => $hubspot_field,
          );
          db_insert('hubspot')
            ->fields($fields)
            ->execute();
        }
      }
    }
  }
}