If you want to alter how a submission is rendered, for example adding a table, you need to implement hook_webform_submission_render_alter(). The hook receive the data for the submission in $renderable['#submission']
, and the node in $renderable['#node']
.
An example of hook_webform_submission_render_alter()
is webform_webform_submission_render_alter(), which contains the following code.
function webform_webform_submission_render_alter(&$renderable) {
// If displaying a submission to end-users who are viewing their own
// submissions (and not through an e-mail), do not show hidden values.
// This needs to be implemented at the level of the entire submission, since
// individual components do not get contextual information about where they
// are being displayed.
$node = $renderable['#node'];
$is_admin = webform_results_access($node);
if (empty($renderable['#email']) && !$is_admin) {
// Find and hide the display of all hidden components.
foreach ($node->webform['components'] as $cid => $component) {
if ($component['type'] == 'hidden') {
$parents = webform_component_parent_keys($node, $component);
$element = &$renderable;
foreach ($parents as $pid) {
$element = &$element[$pid];
}
$element['#access'] = FALSE;
}
}
}
}
The purpose of hook_webform_submission_insert() is inserting the submitted data in a database. You can use that hook to save the data in a database, and show those data in a page rendered from your module, but hook_webform_submission_insert()
is not thought to render any data.
To make a paragon, hook_webform_submission_insert()
is equivalent to hook_node_insert()
that is invoked when a new node is saved, but that should not render any page.