You are here

function _set_summary in Webform Bonus Pack 6.3

Same name and namespace in other branches
  1. 7.3 components/summary.inc \_set_summary()

Form after_build callback function. Set the value property of the form item according to the submitted values.

1 string reference to '_set_summary'
_webform_render_summary in components/summary.inc
Implementation of _webform_render_component().

File

components/summary.inc, line 68
Webform module summary component.

Code

function _set_summary($form_element, &$form_state) {
  global $user;
  module_load_include('inc', 'webform', 'includes/webform.submissions');
  $submitted = $form_state['storage']['submitted'];
  $node = node_load($form_element['#nid']);
  $allowed_components = $node->webform['components'][$form_element['#cid']]['extra']['components'];

  // Show only selected components
  foreach ($submitted as $key => $component) {
    if (!in_array($key, $allowed_components)) {
      unset($submitted[$key]);
    }
  }
  foreach ($node->webform['components'] as $key => $component) {
    if (!in_array($key, $allowed_components)) {
      unset($node->webform['components'][$key]);
    }
  }
  $submission = (object) array(
    'nid' => $node->nid,
    'uid' => $user->uid,
    'submitted' => REQUEST_TIME,
    'remote_addr' => ip_address(),
    'is_draft' => TRUE,
    'data' => webform_submission_data($node, $submitted),
  );
  $form_element['#value'] = webform_submission_render($node, $submission, NULL, 'html');
  return $form_element;
}