function webform_submission_data in Webform 7.4
Same name and namespace in other branches
- 6.3 includes/webform.submissions.inc \webform_submission_data()
- 7.3 includes/webform.submissions.inc \webform_submission_data()
Given an array of submitted values, flatten it into data for a submission.
Parameters
object $node: The node object containing the current webform.
array $submitted: The submitted user values from the webform.
Return value
array An array suitable for use in the 'data' property of a $submission object.
3 calls to webform_submission_data()
- WebformSubmissionTestCase::testPlainComponentsSubmission in tests/
WebformSubmissionTestCase.test - Test webform_submission_data() function.
- webform_client_form_submit in ./
webform.module - Submit handler for saving the form values and sending e-mails.
- webform_submission_create in includes/
webform.submissions.inc - Given set of $form_state values, prepare a psuedo-submission.
File
- includes/
webform.submissions.inc, line 24 - Submission handling functions.
Code
function webform_submission_data($node, $submitted) {
require_once __DIR__ . '/webform.components.inc';
$data = array();
foreach ($submitted as $cid => $values) {
// Don't save pseudo-fields or components that do not collect data.
if (!isset($node->webform['components'][$cid]) || !webform_component_feature($node->webform['components'][$cid]['type'], 'stores_data')) {
continue;
}
if (is_array($values)) {
$data[$cid] = $values;
}
else {
$data[$cid][0] = $values;
}
}
return $data;
}