I have a custom form i created using FAPI and i wanted to submit the values into the webform database table and/or content type as a node. i wasnt sure of the "drupal Way" of doin this. Here's my current submit function, Please tell me if im doing this correctly or if not what is the correct way? (P.S. i dont want to use a different r another module or save to my own custom table.)
function contracts_webform_submit($form, &$form_state) {
module_load_include('inc', 'webform', 'includes/webform.submissions');
module_load_include('inc', 'webform', 'includes/webform.components');
global $user;
$node = $form['#node'];
$sid = $form_state['values']['details']['sid'] ? (int) $form_state['values']['details']['sid'] : NULL;
// If there is no data to be saved (such as on a multipage form with no fields
// on the first page), process no further. Submissions with no data cannot
// be loaded from the database as efficiently, so we don't save them at all.
if (empty($submission->data)) {
return;
}
// Save the submission to the database.
if (!$sid) {
// No sid was found thus insert it in the dataabase.
$form_state['values']['details']['sid'] = $sid = webform_submission_insert($node, $submission);
$form_state['values']['details']['is_new'] = TRUE;
drupal_set_message(t('The form has been submitted.'));
}
}