You are here

function pardot_webform_components_form_submit in Pardot Integration 7

Same name and namespace in other branches
  1. 6 pardot.admin.inc \pardot_webform_components_form_submit()
  2. 7.2 pardot_webform/pardot_webform.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.admin.inc, line 291
Admin forms.

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'];
  }
  $record->nid = $node->nid;
  $record->url = $form_state['values']['details']['url'];
  $record->is_active = (bool) $form_state['values']['details']['is_active'];
  $record->data = $data;
  drupal_write_record('pardot_webform', $record, $update);
}