You are here

function theme_webform_display_view in Webform view 7

Same name and namespace in other branches
  1. 7.4 webform_view.inc \theme_webform_display_view()

Format the output of data for this component.

This renders the data that's been submitted. As seen on the results pages, also used for the email.

1 theme call to theme_webform_display_view()
_webform_display_view in ./webform_view.inc
Implements _webform_display_component().

File

./webform_view.inc, line 475
Additional component for webform that allows views to be used as embeddable elements.

Code

function theme_webform_display_view($variables) {
  $element = $variables['element'];

  // May need to unpack and flatten nested arrays (multiple checkbox options).
  foreach ($element['#value'] as $delta => $row) {
    foreach ($row as $col => $cell) {

      // Some fields may be  so arrive as arrays. Stringify when theming.
      if (is_array($cell)) {
        $element['#value'][$delta][$col] = implode(', ', $cell);
      }
    }
  }

  // Theme the order like a table.
  if ($element['#format'] == 'html') {
    $first_row = reset($element['#value']);
    $header = $first_row ? array_keys($first_row) : array();
    return theme('table', array(
      'header' => $header,
      'rows' => $element['#value'],
    ));
  }
  else {
    return array_to_plaintext_table($element['#value']);
  }
}