function theme_webform_grid in Webform 7.3
Same name and namespace in other branches
- 5.2 components/grid.inc \theme_webform_grid()
- 5 components/grid.inc \theme_webform_grid()
- 6.3 components/grid.inc \theme_webform_grid()
- 6.2 components/grid.inc \theme_webform_grid()
- 7.4 components/grid.inc \theme_webform_grid()
1 theme call to theme_webform_grid()
- _webform_render_grid in components/
grid.inc - Implements _webform_render_component().
File
- components/
grid.inc, line 404 - Webform module grid component.
Code
function theme_webform_grid($variables) {
$element = $variables['element'];
$rows = array();
$header = array(
array(
'data' => '',
'class' => array(
'webform-grid-question',
),
),
);
// Set the header for the table.
foreach ($element['#grid_options'] as $option) {
$header[] = array(
'data' => _webform_filter_xss($option),
'class' => array(
'checkbox',
'webform-grid-option',
),
);
}
foreach (element_children($element) as $key) {
$question_element = $element[$key];
// Create a row with the question title.
$row = array(
array(
'data' => _webform_filter_xss($question_element['#title']),
'class' => array(
'webform-grid-question',
),
),
);
// Render each radio button in the row.
$radios = form_process_radios($question_element);
foreach (element_children($radios) as $key) {
$radios[$key]['#title'] = $question_element['#title'] . ' - ' . $radios[$key]['#title'];
$radios[$key]['#title_display'] = 'invisible';
$row[] = array(
'data' => drupal_render($radios[$key]),
'class' => array(
'checkbox',
'webform-grid-option',
),
);
}
$rows[] = $row;
}
$option_count = count($header) - 1;
return theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'class' => array(
'webform-grid',
'webform-grid-' . $option_count,
),
),
));
}