function theme_webform_matrix in Webform Matrix Component 7.3
Same name and namespace in other branches
- 6 components/matrix.inc \theme_webform_matrix()
- 7 components/matrix.inc \theme_webform_matrix()
- 7.2 components/matrix.inc \theme_webform_matrix()
Theme for webform matrix.
File
- components/
matrix.inc, line 468 - Webform module matrix component.
Code
function theme_webform_matrix($variables) {
$element = $variables['element'];
$component = $element['#webform_component'];
$form_key = $component['form_key'];
$pid = $component['pid'];
$matrix_col = $component['extra']['matrix_col'];
$matrix_row = $component['extra']['matrix_row'];
//Matrix rows and cols
$headers = $element['#headers'];
$rows = array();
for ($i = 1; $i <= $matrix_row; $i++) {
$cols = array();
for ($j = 1; $j <= $matrix_col; $j++) {
$cols[] = drupal_render($element[$i][$j]);
}
$rows[] = $cols;
}
$form_class = str_replace('_', '-', $form_key);
$output = "<div class='form-item webform-component webform-component-matrix webform-component--{$form_class}' id='webform-component-{$form_class}'>";
//Check if title_display checkbox is unchecked
$output .= isset($element['#main_header']) ? "<label>" . $element['#main_header'] . "</label>" : "";
$output .= theme('table', array(
'header' => $headers,
'rows' => $rows,
));
$output .= drupal_render_children($element);
$output .= "</div>";
return $output;
}