You are here

function pardot_webform_components_form_submit in Pardot Integration 6

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

File

./pardot.admin.inc, line 79

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