function theme_fel_fields_matrix_table in Form element layout 7
Theme replacement for 'matrix_table'.
See also
File
- modules/
fel_fields/ fel_fields.theme.inc, line 177 - Theme replacement functions for Form element layout fields.
Code
function theme_fel_fields_matrix_table($variables) {
$form = $variables['form'];
$rows_count = $form['#matrix_rows'];
$cols_count = $form['#matrix_cols'];
$more_cols = $form['#matrix_more_cols'];
$more_rows = $form['#matrix_more_rows'];
$column_labels = $form['#column_labels'];
$row_labels = $form['#row_labels'];
$field_name = $form['#field_name'];
$table_rows = array();
for ($row = 1; $row <= $rows_count; $row++) {
for ($col = 1; $col <= $cols_count; $col++) {
$table_rows[$row - 1][$col - 1] = drupal_render($form['grid'][$row . '-' . $col]);
}
}
if (!empty($row_labels)) {
array_unshift($column_labels, '');
foreach ($row_labels as $id => $label) {
array_unshift($table_rows[$id - 1], $label);
}
}
if ($more_rows) {
$table_rows[$rows_count][1] = drupal_render($form['more_rows']);
for ($col = 2; $col <= $cols_count; $col++) {
$table_rows[$rows_count][$col] = ' ';
}
}
if ($more_cols) {
$column_labels[] = drupal_render($form['more_cols']);
for ($row = 1; $row <= $rows_count; $row++) {
$table_rows[$row - 1][$cols_count + 1] = ' ';
}
}
$parts = array(
'title' => theme('fel_form_element_label', array(
'element' => $form,
)),
'children' => theme('table', array(
'header' => $column_labels,
'rows' => $table_rows,
)),
);
if (!empty($form['#description'])) {
$form['#description'] = filter_xss_admin($form['#description']);
$parts['description'] = theme('fel_form_element_description', array(
'element' => $form,
));
}
$output = '<div id="matrix-field-' . $field_name . '">';
$output .= fel_order_output($form, $parts);
$output .= '</div>';
return $output;
}