function theme_webform_display_grid in Webform 6.3
Same name and namespace in other branches
- 7.4 components/grid.inc \theme_webform_display_grid()
- 7.3 components/grid.inc \theme_webform_display_grid()
Format the text output for this component.
1 theme call to theme_webform_display_grid()
- _webform_display_grid in components/
grid.inc - Implements _webform_display_component().
File
- components/
grid.inc, line 256 - Webform module grid component.
Code
function theme_webform_display_grid($element) {
$component = $element['#webform_component'];
$format = $element['#format'];
if ($format == 'html') {
$rows = array();
$header = array(
array(
'data' => '',
'class' => 'webform-grid-question',
),
);
foreach ($element['#grid_options'] as $option) {
$header[] = array(
'data' => _webform_filter_xss($option),
'class' => 'checkbox webform-grid-option',
);
}
foreach (element_children($element) as $key) {
$row = array();
$row[] = array(
'data' => _webform_filter_xss($element[$key]['#title']),
'class' => 'webform-grid-question',
);
foreach ($element['#grid_options'] as $option_value => $option_label) {
if (strcmp($option_value, $element[$key]['#value']) == 0) {
$row[] = array(
'data' => '<strong>X</strong>',
'class' => 'checkbox webform-grid-option',
);
}
else {
$row[] = array(
'data' => ' ',
'class' => 'checkbox webform-grid-option',
);
}
}
$rows[] = $row;
}
$option_count = count($header) - 1;
$output = theme('table', $header, $rows, array(
'class' => 'webform-grid webform-grid-' . $option_count,
));
}
else {
$items = array();
foreach (element_children($element) as $key) {
$items[] = ' - ' . $element[$key]['#title'] . ': ' . (isset($element['#grid_options'][$element[$key]['#value']]) ? $element['#grid_options'][$element[$key]['#value']] : '');
}
$output = implode("\n", $items);
}
return $output;
}