You are here

function _webform_submission_display_grid in Webform 5

Same name and namespace in other branches
  1. 5.2 components/grid.inc \_webform_submission_display_grid()
  2. 6.2 components/grid.inc \_webform_submission_display_grid()

Display the result of a grid submission. The output of this function will be displayed under the "results" tab then "submissions"

Parameters

$data: An array of information containing the submission result, directly correlating to the webform_submitted_data database schema

$component: An array of information describing the component, directly correlating to the webform_component database schema

Return value

Textual output formatted for human reading.

File

components/grid.inc, line 129

Code

function _webform_submission_display_grid($data, $component, $enabled = FALSE) {
  $form_item = _webform_render_grid($component, FALSE);
  $cid = 0;
  foreach (element_children($form_item) as $key) {
    $value = $data['value'][$cid++];
    if ($value !== '0') {
      if (array_key_exists(_webform_safe_name($value), $form_item[$key]['#options'])) {
        $form_item[$key]['#default_value'] = _webform_safe_name($value);
      }
      else {
        $form_item[$key]['#default_value'] = $value;
      }
    }
    $form_item[$key]['#disabled'] = !$enabled;
  }
  return $form_item;
}