You are here

function webform_submission_data in Webform 7.3

Same name and namespace in other branches
  1. 6.3 includes/webform.submissions.inc \webform_submission_data()
  2. 7.4 includes/webform.submissions.inc \webform_submission_data()

Given an array of submitted values, flatten it into data for a submission.

Parameters

$node: The node object containing the current webform.

$submitted: The submitted user values from the webform.

Return value

An array suitable for use in the 'data' property of a $submission object.

1 call to webform_submission_data()
webform_client_form_submit in ./webform.module
Submit handler for saving the form values and sending e-mails.

File

includes/webform.submissions.inc, line 22
This file is loaded when handling submissions, either submitting new, editing, or viewing. It also contains all CRUD functions for submissions.

Code

function webform_submission_data($node, $submitted) {
  $data = array();
  foreach ($submitted as $cid => $values) {

    // Don't save pagebreaks as submitted data.
    if ($node->webform['components'][$cid]['type'] == 'pagebreak') {
      continue;
    }
    if (is_array($values)) {
      $data[$cid]['value'] = $values;
    }
    else {
      $data[$cid]['value'][0] = $values;
    }
  }
  return $data;
}