You are here

function theme_matrix_table_form in Matrix field 6.2

Same name and namespace in other branches
  1. 5 matrix.module \theme_matrix_table_form()
  2. 6 matrix.module \theme_matrix_table_form()

Theme the matrix elements into a table

1 theme call to theme_matrix_table_form()
matrix_table_process in ./matrix.module
Process the table type element before displaying the field.

File

./matrix.module, line 435
Defines simple matrix field types.

Code

function theme_matrix_table_form($form) {
  $rows = array();
  $header = (array) $form['#header'];
  $first_col = (array) $form['#first_col'];
  $field = content_fields($form['#field_name']);
  switch ($field['widget']['type']) {
    case 'table':
      $row = array(
        '',
      );

      //first must be blank
      foreach ($form['#cols_elements'] as $col_key => $field) {
        $row[$col_key + 1] = drupal_render($form[$col_key]);
      }
      $rows[] =& $row;
      break;
    case 'matrix':
      foreach ($form as $row_key => $fields) {
        if (is_numeric($row_key)) {

          //ignore all other properties
          unset($row);
          $row[] = $first_col[$row_key];
          foreach ($fields as $col_key => $field) {
            if (is_numeric($col_key)) {
              $row[] = drupal_render($form[$col_key]);
            }
          }
          $rows[] = $row;
        }
      }
      break;
  }
  $output = theme('table', $header, $rows, array(
    'class' => 'matrix',
  ));
  $output .= drupal_render($form);
  return theme('form_element', $form, $output);
}