You are here

function theme_biblio_contributors in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/biblio_theme.inc \theme_biblio_contributors()
  2. 6 biblio_theme.inc \theme_biblio_contributors()
  3. 7.2 includes/biblio.theme.inc \theme_biblio_contributors()

Parameters

$form:

1 theme call to theme_biblio_contributors()
biblio_contributor_widget in ./biblio.module

File

includes/biblio_theme.inc, line 1120

Code

function theme_biblio_contributors($variables) {
  $form = $variables['form'];
  $rows = array();
  $headers = array(
    '',
    t('Name'),
    t('Category'),
    t('Role'),
    t('Weight'),
  );
  drupal_add_tabledrag($form['#id'], 'order', 'sibling', 'rank');
  foreach (element_children($form) as $key) {

    // No need to print the field title every time.
    //    unset($form[$key]['name']['#title'], $form[$key]['auth_type']['#title'], $form[$key]['auth_category']['#title']);
    // Add class to group weight fields for drag and drop.
    $form[$key]['rank']['#attributes']['class'] = array(
      'rank',
    );

    // Build the table row.
    $row = array(
      '',
    );
    $row[] = array(
      'data' => drupal_render($form[$key]['name']),
      'class' => array(
        'biblio-contributor',
      ),
    );
    $row[] = array(
      'data' => drupal_render($form[$key]['auth_category']),
      'class' => array(
        'biblio-contributor-category',
      ),
    );
    $row[] = array(
      'data' => drupal_render($form[$key]['auth_type']),
      'class' => array(
        'biblio-contributor-type',
      ),
    );
    $row[] = drupal_render($form[$key]['rank']);
    $rows[] = array(
      'data' => $row,
      'class' => array(
        'draggable',
      ),
    );
  }
  $output = theme('table', array(
    'header' => $headers,
    'rows' => $rows,
    'attributes' => array(
      'id' => $form['#id'],
    ),
  ));

  // $output .= drupal_render_children($form);
  return $output;
}