function webform_submission_render in Webform 7.4
Same name and namespace in other branches
- 6.3 includes/webform.submissions.inc \webform_submission_render()
- 7.3 includes/webform.submissions.inc \webform_submission_render()
Prepare a Webform submission for display on a page or in an e-mail.
Parameters
object $node: The node object.
object $submission: The submission object.
array $email: The email configuration array.
string $format: The format the form should be displayed as. May be one of the following:
- form: Show as an editable form.
- html: Show as HTML results.
- text: Show as plain text.
array $excluded_components: An array of components to exclude as cid.
Return value
array A renderable array of the submission.
4 calls to webform_submission_render()
- webform_client_form in ./
webform.module - Client form generation function.
- webform_submission_page in includes/
webform.submissions.inc - Menu callback; Present a Webform submission page for display or editing.
- webform_tokens in ./
webform.tokens.inc - Implements hook_tokens().
- webform_views_plugin_row_submission_view::render in views/
webform_plugin_row_submission_view.inc - Render a row object. This usually passes through to a theme template of some form, but not always.
File
- includes/
webform.submissions.inc, line 691 - Submission handling functions.
Code
function webform_submission_render($node, $submission, $email, $format, $excluded_components = NULL) {
$component_tree = array();
$renderable = array();
$page_count = 1;
// Meta data that may be useful for modules implementing
// hook_webform_submission_render_alter().
$renderable['#node'] = $node;
$renderable['#submission'] = $submission;
$renderable['#email'] = $email;
$renderable['#format'] = $format;
// Set the theme function for submissions.
$renderable['#theme'] = array(
'webform_submission_' . $node->nid,
'webform_submission',
);
$components = $node->webform['components'];
// Remove excluded components.
if (is_array($excluded_components)) {
foreach ($excluded_components as $cid) {
unset($components[$cid]);
}
if (!empty($email['exclude_empty'])) {
foreach ($submission->data as $cid => $data) {
// Caution. Grids store their data in an array index by question key.
if (implode($data) == '') {
unset($components[$cid]);
}
}
}
}
module_load_include('inc', 'webform', 'includes/webform.components');
_webform_components_tree_build($components, $component_tree, 0, $page_count);
// Make sure at least one field is available.
if (isset($component_tree['children'])) {
// Recursively add components to the form.
$sorter = webform_get_conditional_sorter($node);
$input_values = $sorter
->executeConditionals($submission->data);
foreach ($component_tree['children'] as $cid => $component) {
if ($sorter
->componentVisibility($cid, $component['page_num']) == webformConditionals::componentShown) {
_webform_client_form_add_component($node, $component, NULL, $renderable, $renderable, $input_values, $format);
}
}
}
drupal_alter('webform_submission_render', $renderable);
return $renderable;
}