You are here

function pardot_webform_components_form_submit in Pardot Integration 7.2

Same name and namespace in other branches
  1. 6 pardot.admin.inc \pardot_webform_components_form_submit()
  2. 7 pardot.admin.inc \pardot_webform_components_form_submit()

Form submission handler for pardot_webform_components_form().

Saves the pardot post url and webform information to the database.

See also

pardot_webform_components_form_validate()

File

pardot_webform/pardot_webform.admin.inc, line 156
Webform admin file.

Code

function pardot_webform_components_form_submit($form, $form_state) {
  $node = $form['#node'];
  $record = $form['#record'];
  if ($record) {
    $update = array(
      'nid',
    );
  }
  else {
    $record = new stdClass();
    $update = array();
  }
  $data = array();
  foreach (element_children($form['components']) as $k) {
    $component = $form['components'][$k]['#component'];
    $data[$component['form_key']]['key'] = $form_state['values']['components'][$k]['key'];
  }

  // Will will replace any previous entries.
  db_delete('pardot_webform')
    ->condition('nid', $node->nid)
    ->execute();
  db_insert('pardot_webform')
    ->fields(array(
    'nid' => $node->nid,
    'url' => $form_state['values']['details']['url'],
    'is_active' => (bool) $form_state['values']['details']['is_active'],
    'data' => serialize($data),
  ))
    ->execute();
}