You are here

function _webform_display_matrix in Webform Matrix Component 7.4

Same name and namespace in other branches
  1. 6 components/matrix.inc \_webform_display_matrix()
  2. 7 components/matrix.inc \_webform_display_matrix()
  3. 7.2 components/matrix.inc \_webform_display_matrix()
  4. 7.3 components/matrix.inc \_webform_display_matrix()

Implements _webform_display_component().

File

components/matrix.inc, line 584
Webform module matrix component.

Code

function _webform_display_matrix($component, $value, $format = 'html') {
  $headers = array();
  $value_array = isset($value[0]) ? unserialize($value[0]) : '';
  if (empty($value_array)) {
    return array();
  }
  $sub_elements = $component['extra']['element'];
  $display_array = _webform_display_array($sub_elements, $value_array, $headers);
  $matrix_value = array(
    'headers' => $headers,
    'rows' => $display_array,
  );
  return array(
    '#title' => $component['name'],
    '#weight' => $component['weight'],
    '#theme' => 'webform_display_matrix',
    '#theme_wrappers' => $format == 'html' ? array(
      'webform_element',
    ) : array(
      'webform_element_text',
    ),
    '#format' => $format,
    '#value' => $matrix_value,
    '#translatable' => array(
      'title',
    ),
  );
}