You are here

function theme_matrix_table_form in Matrix field 5

Same name and namespace in other branches
  1. 6.2 matrix.module \theme_matrix_table_form()
  2. 6 matrix.module \theme_matrix_table_form()
1 theme call to theme_matrix_table_form()
matrix_widget in ./matrix.module
Implementation of hook_widget().

File

./matrix.module, line 212

Code

function theme_matrix_table_form($form) {
  if (empty($form)) {
    return t('No matrix rows and columns defined yet.');
  }
  $rows = array();
  $header = $form['header']['#value'];
  foreach ($form as $row_key => $fields) {
    if (!empty($form['first_col']['#value'][$row_key])) {
      $row = array();
      $row[] = $form['first_col']['#value'][$row_key];
      foreach ($fields as $col_key => $field) {
        if ($field['#type'] == 'textfield') {
          $row[] = drupal_render($form[$row_key][$col_key]);
        }
      }
      $rows[] = $row;
    }
  }
  drupal_render($form['header']);
  drupal_render($form['first_col']);
  $output = drupal_render($form);
  $output .= theme('table', $header, $rows, array(
    'class' => 'matrix',
  ));
  return $output;
}